79203694

Date: 2024-11-19 14:01:04
Score: 1.5
Natty:
Report link

Did some more digging and found the following solution

var selfJoin = 
    from child in Context.GlobalDocumentClassification
    from parent in Context.GlobalDocumentClassification
    select new { child, parent };

var query = from item in selfJoin
    where item.child.HierarchyId.IsDescendantOf(item.parent.HierarchyId) &&
        EF.Constant(ids).Contains(item.parent.Id)
    select item.child.Id;

code

This produces SQL-Server cross join query and allows for the use of IsDescendantOf() in the queries where clause.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Starts with a question (0.5): Did some
  • Low reputation (0.5):
Posted by: Norbert Hüthmayr