Return category hierarchy in a string like "cat1 > cat2 > cat3"
I have an SQL table in the following format:
id categoryname parent id
1 cat1 0
2 cat2 1
3 cat3 2
4 cat4 0
5 cat5 4
how can i return a string like "cat1 > cat2 > cat3" when querying "3" or "cat4 > cat5" wh开发者_如何转开发en querying "4" in asp.net? It isn't always going to be three categoryies deep.. i've never done a recursive query before.. can this be done using linq?
Have a look at this hierarchical-data-in-linq-options-and-performance providing a way to fetch hierarhical data using LINQ.
精彩评论