admin管理员组文章数量:1026989
I need to find all descendants for a given list of parents. The query (in plain SQL) was easy enough, but I can't translate it into LINQ-to-SQL.
SQL Query:
select child.id from GlobalDocumentClassification child
inner join GlobalDocumentClassification parent
on child.HierarchyId.IsDescendantOf(parent.HierarchyId) = CAST(1 AS bit) and
parent.Id in ('5bb9450f-3778-411d-bbf2-5a5775c70310')
Here my (flawed) LINQ query:
var entityIds =
from child in Context.GlobalDocumentClassification
join parent in Context.GlobalDocumentClassification
on child.HierarchyId.IsDescendantOf(child.HierarchyId) equals true
where EF.Constant(documentClassificationIds).Contains(parent.Id)
select child.Id;
The IDE complains about the use of parent
- I believe this is related to how the LINQ-to-SQL queries need to be structured
I need to find all descendants for a given list of parents. The query (in plain SQL) was easy enough, but I can't translate it into LINQ-to-SQL.
SQL Query:
select child.id from GlobalDocumentClassification child
inner join GlobalDocumentClassification parent
on child.HierarchyId.IsDescendantOf(parent.HierarchyId) = CAST(1 AS bit) and
parent.Id in ('5bb9450f-3778-411d-bbf2-5a5775c70310')
Here my (flawed) LINQ query:
var entityIds =
from child in Context.GlobalDocumentClassification
join parent in Context.GlobalDocumentClassification
on child.HierarchyId.IsDescendantOf(child.HierarchyId) equals true
where EF.Constant(documentClassificationIds).Contains(parent.Id)
select child.Id;
The IDE complains about the use of parent
- I believe this is related to how the LINQ-to-SQL queries need to be structured
本文标签: cHierarchyID Get all descendants for a list of parents using LINQtoSQLStack Overflow
版权声明:本文标题:c# - HierarchyID: Get all descendants for a list of parents using LINQ-to-SQL - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745590476a2157855.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论