我有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那样序列化对象。我该如何解决这个问题?