我试图将模型发送到wcf服务。 首先我有一个序列化的问题,但我解决它通过设置实体框架4.0模型不能获取所有数据
ContextOptions.ProxyCreationEnabled = false;
引荐DataContractSerializer Error using Entity Framework 4.0 with WCF 4.0 但现在的模型属性税和产品都为空
public ClientWindowViewModel()
{
Ip = ServerWindowViewModel.LocalIP;
db = new STOREDBEntities();
db.Configuration.ProxyCreationEnabled = false;
products = db.Products;//.Where(p => p.IsSynced == false)
}
产品型号
public partial class Product
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Product()
{
this.Categories = new HashSet<Category>();
}
public int Id { get; set; }
public string ProductName { get; set; }
public byte[] Image { get; set; }
public bool IsDeleted { get; set; }
public bool IsSynced { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Category> Categories { get; set; }
public virtual Tax Tax { get; set; }
}
发送到WCF服务器
channel.Update(checkedProducts);
是的。我找到答案见上面:) –