【问题标题】:Breeze,js error Collection navigation properties may NOT be setBreeze,js 错误集合导航属性可能未设置
【发布时间】:2013-02-17 04:37:43
【问题描述】:

当我尝试向导航添加新对象时收到此错误 不能设置集合导航属性。

这是我的 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);

有人能指出我正确的方向吗?

编辑: 我忘了提到我在多对多关系中遇到了这个错误,只是在文档中读到这还不支持。

是否有任何解决方法?

【问题讨论】:

    标签: breeze


    【解决方案1】:

    恐怕唯一的解决方法是将两种类型之间的映射公开为它自己的实体。

    正如我在其他地方所说,我不喜欢将映射对象隐藏在 EF m-to-m 关联后面。这种伪装似乎总是造成比其价值更多的麻烦。映射获得有效负载的那一刻——链接日期、版本、租户标识符——任何东西——m-to-m 分崩离析,必须定义映射对象。根据我的经验,那个“时刻”迟早会到来。它出现的越晚,它造成的麻烦就越多。所以我建议在成本低的时候把它暴露出来。这对你来说可能吗?

    【讨论】:

    • 感谢您的回答。你能给我举一个这种映射曝光的例子吗?
    • 在路上。 EF m-to-m 上的网络搜索应该可以参考 Julie Lerman 的书来解释它。
    猜你喜欢
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-25
    • 1970-01-01
    • 2012-12-06
    • 1970-01-01
    相关资源
    最近更新 更多