Walking a hierarchy table with Linq

后端 未结 3 1728
离开以前
离开以前 2021-01-14 06:10

I have a table with two columns, GroupId and ParentId (both are GUIDS). The table forms a hierarchy so I can look for a value in the “GroupId” filed, when I have found it I

3条回答
  •  粉色の甜心
    2021-01-14 06:40

    The other respondents are right - performance is going to be pretty bad on this, since you'll have to make multiple round-trips. This will be somewhat dependent on your particular case, however - is your tree deep and will be people be performing this operation often, for instance.

    You may be well served by creating a stored procedure that does this (using a CTE), and wiring it up in the Entities Designer to return your particularly defined Entity.

提交回复
热议问题