开发者

Return category hierarchy in a string like "cat1 > cat2 > cat3"

开发者 https://www.devze.com 2023-03-19 09:46 出处:网络
I have an SQL table in the following format: id categoryname parent id 1 cat10 2 cat21 3 cat32 4 cat40 5 cat54

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消