문제

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 !!

도움이 되었습니까?

해결책

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).

https://stackoverflow.com/a/14764333/853295

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top