当我尝试克隆一个Product-object 并将克隆保存到数据库时,原始对象会丢失它的所有关系数据,例如ProductPropertyOptionForProducts,IdentifierForProducts和InCategories。这是产品型号:public class Product{ public int Id { get; set; } public int ProductGroupId { get; set; } public int ProductGroupSortOrder { get; set; } [Required, MaxLength(30), MinLength(4)] public string Title { get; set; } [MaxLength(200)] public string Info { get; set; } [MaxLength(4000)] public string LongInfo { get; set; } [Required, DataType(DataType.Currency)] public decimal Price { get; set; } public int Weight { get; set; } public int ProductTypeId { get; set; } public ICollection<ProductImage> Images { get; set; } // Selected property options for this product public ICollection<PropertyOptionForProduct> ProductPropertyOptionForProducts { get; set; } // A product can have multiple identifiers (EAN, ISBN, product number, etc.) public ICollection<IdentifierForProduct> IdentifierForProducts { get; set; } public ProductType Type { get; set; } public ICollection<FrontPageProduct> InFrontPages { get; set; } public ICollection<ProductInCategory> InCategories { get; set; }}一些相关模型:public class ProductInCategory// A linking table for which products belongs to which categories{ public int Id { get; set; } public int ProductId { get; set; } public int ProductCategoryId { get; set; } public int SortOrder { get; set; } // Nav.props.: public Product Product { get; set; } public ProductCategory ProductCategory { get; set; }}
1 回答
- 1 回答
- 0 关注
- 95 浏览
添加回答
举报
0/150
提交
取消