开发者

Child objects in domain class

I have a domain class like

public class Category
{
    [Key]
    public string IdCategory { get; set; }
    public string Name { get; set; }
    public List<Category> Children { get; set; }
    public List<Product> Products { 开发者_Python百科get; set; }



    public Category()
    {
        Products = new List<Product>();
        Children = new List<Category>();
    }

}

In the generated code I find the products collection, but not the children collection. There are some restriction about using the same class? There is another way to modeling this relation without recurring to keys?


public  class Category
    {
        [Key]
        public string IdCategory { get; set; }
        public string Name { get; set; }
        public string IdFather { get; set; }
        public List<Product> Products { get; set; }
        [Include]            
        [Association("ParentChild", "IdCategory", "IdFather")]
        public List<Category> Children { get; set; }




        public Category()
        {
            Products = new List<Product>();
            Children = new List<Category>();

        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜