Answer the question
In order to leave comments, you need to log in
How to properly organize and control the hierarchy in the database using the entity framework?
Good day to all! For the first time I work with hierarchy in a DB. In general, it was necessary to organize a group with a hierarchy. And created the following model:
public class MyGroup
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public virtual List<MyGroup> Childrens { get; set; }
public virtual MyGroup Parent { get; set; }
}
Answer the question
In order to leave comments, you need to log in
I found a solution, but there is also a minus. Specify nesting level. It seems to solve the problem, but the problem arises if you move a group with nesting of the 3rd level to the first and if it contains several more nested groups.
For example, we have "root group1" (level 0) and contains several groups nested up to level 7. The whole problem starts if we move the group with level 4 to "root group 1". How to deal with child groups of this group. Their nesting level is no longer 5 or 6 or 7 though. What are the ways to solve this problem? It only comes to mind to vyat everyone and change the nesting level to the desired one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question