This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to build Linq query using HierarchyId.IsDescendantOf() against Data Access Model.
I'm trying to build Linq query using HierarchyId.IsDescendantOf() against Data Access Model.
int
folderTreeId = 123;
var parentId = (from folder
in
context.FolderInfos
where folder.FolderTreeID == folderTreeId
select folder.FolderHierarchyID).Single();
var folders = from folder
in
context.FolderInfos
where folder.FolderHierarchyID.IsDescendantOf(parentId).Value ==
true
select folder;
First query works fine and returns SqlHierarchyId type. Second returns an exception because generated SQL contains invalid WHERE clause.
(FROM [iRooms].[FolderInfo] a WHERE a.[FolderHierarchyID].IsDescendantOf(?) = (1=1))
Is it possible to write such queries with Linq and HierarchyId? If not, what would be other option to write similar query using Data Access.
Regards,
Marcin