Breeze,js错误可能未设置集合导航属性 [英] Breeze,js error Collection navigation properties may NOT be set
问题描述
当我尝试向导航
中添加新对象时,我收到此错误,可能未设置集合导航属性。
I am receiving the this error when i try to add a new object to the navigation Collection navigation properties may NOT be set.
这是我的POCO:
public class Category : BaseEntity,IDeletable
{
public Category()
{
Products = new List<Product>();
ChildCategories = new List<Category>();
}
[Required]
[Display(ResourceType = typeof(DelkaShop.Entities.EntityText.EntityText), Name = "EntityName")]
public String Name { get; set; }
[Display(ResourceType = typeof(DelkaShop.Entities.EntityText.EntityText), Name = "ParentCategory")]
public int? ParentCategoryId { get; set; }
[Display(ResourceType = typeof(DelkaShop.Entities.EntityText.EntityText), Name = "ItemsPerPage")]
public int? ItemsPerPage { get; set; }
[InverseProperty("Categories")]
public ICollection<Product> Products { get; set; }
[ForeignKey("ParentCategoryId")]
[Display(ResourceType = typeof(DelkaShop.Entities.EntityText.EntityText), Name = "ParentCategory")]
public Category ParentCategory { get; set; }
public ICollection<Category> ChildCategories { get; set; }
}
在微风中,我在做类似
的事情product.Categories.push(newCategoryObject);
in breeze i am doing somehting like product.Categories.push(newCategoryObject);
有人可以指出我正确的方向吗?
Can somebody point me into the right direction?
编辑:
我忘了提及我因多对多关系而遇到此错误,只是在文档中读到尚不支持此错误。
I forgot to mention that i am getting this error for a many to many relationship and just read in the documentation that this is not supported yet.
是否存在
推荐答案
恐怕唯一的解决方法是公开这两种类型之间的映射作为自己的实体。
I'm afraid that the only work-around is to expose the mapping between the two types as its own entity.
正如我在其他地方所说,我不喜欢将映射对象隐藏在EF m-m关联的后面。这种伪装似乎总是造成比其价值更大的麻烦。映射获得有效负载的那一刻-链接日期,版本,租户标识符-任何东西-m对m崩溃,必须定义映射对象。根据我的经验,这种时刻迟早会到来。出现的越晚,造成的麻烦就越大。因此,我建议在成本较低的情况下立即进行曝光。你有可能吗?
As I've said elsewhere, I'm not fond of hiding the mapping object behind the EF m-to-m association. That disguise always seems to create far more trouble than it is worth. The moment that the mapping gains a payload - a link-date, version, tenant-identifier - anything - the m-to-m falls apart and the mapping object must be defined. That "moment" arrives sooner or later in my experience. The later it arises, the more trouble it causes. So I recommend exposing it now while the cost is low. Is that possible for you?
这篇关于Breeze,js错误可能未设置集合导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!