【发布时间】:2017-11-11 15:49:30
【问题描述】:
我正在尝试将模型发送到 wcf 服务。 首先我有一个序列化问题,但我通过设置解决了它
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);
【问题讨论】:
标签: c# entity-framework wcf