The code is a small scale of my problem:
public class Category { public Guid CategoryID { get; set; } public string Name { get; set; } public Guid? ParentID { get; set; } public bool IsTop { get; set; } public string Description { get; set; } public virtual Category parentCategory { get; set; } }
When I use this class in the Entity Framework, it generates only one relation of parent and child categories.
How can I say, to semantically separate properties and generate two different relationships in SQL Server, to get all child categories (child relationships of a child (recursive from top to bottom)) and the other to get all parent categories (parent of a parent (recursive from bottom to top) )? Something like that:
public virtual ICollection<Category> childCategories { get; set;} public virtual ICollection<Category> parentCategories { get; set;}
I tried this with modelBuilder, but from there I can only get one level of detail.
Milan Mendpara
source share