See my answer here to get a parent and all children/grand children and so on back from a sql query (will return the complete tree structure).
how to show hierarchical data from table with hierarchyid data type in tree view in vb.net?
-
04-10-2022 - |
题
I have a table with this structure :
create table shajare (
node hierarchyid PRIMARY KEY CLUSTERED ,
level AS node.GetLevel() PERSISTED,
person_id int Unique,
person_name Nvarchar(30) Not null);
and I use this in SQL Server to show all children of a given parent:
select *
from shajare as parent
inner join shajare as child on child.node.IsDescendantOf(parent.node) = 1
where parent.person_id = 12
How can I show the children of a parent in a tree view by do not using recursive function or using some thing like that SQL code but by linq ? My boss asked for linq???
Please !!
解决方案
不隶属于 StackOverflow