CTE recursive query with linq mvc

My table for a category is something like: categoryId,cat_name,parentId

I want to get all child categories from the root (category) at the bottom of the tree in a hierarchical form as the parent-child relation to linq, as well as im, using the model structure mvc3 EF ...

suggest some solution for this ...

Thanks in advance, Milan

+4
source share
1 answer

if you want to do this without creating a function to recursively generate a query for each node of the tree, you should consider switching to a nested set architecture rather than a parent / child architecture. this allows you to get the node of all descendants with a single query. read this article on this topic for more information: http://www.sitepoint.com/hierarchical-data-database/ (be sure to read all this. Good things don't start until the second page.)

+2
source

Source: https://habr.com/ru/post/1392971/


All Articles