实体框架数据库首先将生成的类暴露为Datacontract

时间:2014-03-16 15:20:55

标签: c# entity-framework datacontract edmx-designer

我创建了一个Web服务,它应该返回一个实体&UserCrofile'。大多数操作返回预期的结果,但是当我直接返回生成的类时,我得到空响应。

服务:

List<UserProfile> IMusicOwnerService.getProfiles()
    {
        return context.UserProfileSet.ToList();
    }

请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:getProfiles/>
   </soapenv:Body>
</soapenv:Envelope>

我修改了Model.tt文件(according to this answer) 然后生成了这个类:

    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;  //Template modification test
    [DataContract]//Template modification test
    public partial class UserProfile
    {

        public UserProfile()
        {
            this.LoginSession = new HashSet<LoginSession>();
            this.Playlist = new HashSet<Playlist>();
            this.Friends = new HashSet<UserProfile>();
            this.Song = new HashSet<Song>();
        }

        [DataMember]//Template modification test
        public int Id { get; set; }
        [DataMember]//Template modification test
        public string UserName { get; set; }
        [DataMember]//Template modification test
        public string Email { get; set; }
        [DataMember]//Template modification test
        public string Password { get; set; }
        [DataMember]//Template modification test
        public string Salt { get; set; }

}

发送请求时无响应。

http://imgur.com/AvtTmNE (发布图片的声誉不够)

0 个答案:

没有答案