Using IsDescendantOf with LINQ
-
I am attempting to use Linq to filter a datatable to get the descendants of a node based on SQLHierarchyID. This compiles but does not return any results, the same query in TSQL returns the correct records.
//filter the table using linq.
EnumerableRowCollection query = from TNodes in oTable.AsEnumerable()
where TNodes.Field("NodeKey").IsDescendantOf(hID).Equals(true)
select TNodes;Any suggestions welcome.
-
I am attempting to use Linq to filter a datatable to get the descendants of a node based on SQLHierarchyID. This compiles but does not return any results, the same query in TSQL returns the correct records.
//filter the table using linq.
EnumerableRowCollection query = from TNodes in oTable.AsEnumerable()
where TNodes.Field("NodeKey").IsDescendantOf(hID).Equals(true)
select TNodes;Any suggestions welcome.
-
Can I see a sample of your xml, im sure this one should be easy enough. Edit: I mean the xml generated by your dataset, so I could test a solution.
Mycroft Holmes wrote:
.Equals(true)
That bit should be superfluous.
J4amieC wrote:
Can I see a sample of your xml, im sure this one should be easy enough.
Nope, it's 6pm and I'm sitting here (at home) with a nice glass of white and that bloody thing has been left in the office. VS grumbled until I put the .Equals on the end. The only relevant thing should be that the NodeKey is a SQLHierarchyID I would think. I eventually chucked linq and went back to a stored proc to do the job - I'm seriously not happy with linq as it continually dissapoints.
Never underestimate the power of human stupidity RAH