I have this code to find the root of a tree node:
Guid? currentNode = null;
var root = db.RecursiveTrees.Where(x => x.ParentId == currentNode).ToList();
This query returns 0 results.
If I run this query, I get the expected line:
var root = db.RecursiveTrees.Where(x => x.ParentId == null).ToList();
Why does the first request not work (using the latest version of the entity framework)?
EDIT:
Workaround:
List<RecursiveTree> root;
if (nodeid == null)
root = db.RecursiveTrees.Where(x => x.ParentId == null).ToList();
else
root = db.RecursiveTrees.Where(x => x.ParentId == new Guid(nodeid)).ToList();
source
share