如何序列化ICollection以将其从客户端传输到服务器

时间:2015-04-02 04:34:28

标签: entity-framework wcf

我有EntityFramework自动生成的clsses,我想将它们序列化以传输到服务器。例如:

 [DataContract(IsReference = true)]
     [KnownType(typeof(ObservableCollection<UserProp>))]
    public partial class DirectionWork
    {

        public DirectionWork()
        {
        this.UserProp = new HashSet<UserProp>();
    }
    [DataMember]
    public int IdDirectionOfWork { get; set; }
    [DataMember]
    public string DirectionWork1 { get; set; }
    [DataMember]
    public virtual ICollection<UserProp> UserProp { get; set; }
}

但我无法像ICollection那样序列化对象。我该如何解决这个问题?

0 个答案:

没有答案