![]() Define a partial classe Node and add a propert Children of type List(don't use the property that EF create for you for the s a data structure based on Lazy Loading. Now suppose that the class of each Node is just called Node. Now since on this table there is a relation on itself that connect each node with each children EF will create a property that give you the father of each Node call it Parent. ![]() The simplest way is by doing recursive calls to the database firts retrieve the root with its children, then for each child retrieve recursively its childre, and so on.However this is very inefficient! Too many accesses to the DB to retrieve just a feīetter to read the whole table and put it into a List, call it menuList. (),ĮXISTS(select 1 from artomlii child where eeparent=eeorder ) as haschildrenįoreach (dynamic row in row.nimetus, row.id) Void ProcessLevel(StringBuilder sb, string treeParent) Treeparent - parend id in this column of empty for root menu Treeorder - determines id and order of menu items What is best practive to implement this is MVC ? Shoult I move it to view to aspx file ? If yes how to create recursive view which renders child nodes also ? This renders first level properly but does not render child nodes. ![]() How to generate hierarchical menu below in Menu method from database data ? Should I use stringbuilder or is there better way ?
0 Comments
Leave a Reply. |