我試圖將模型發送到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);
是的。我找到答案見上面:) –