Hi, I've got a basic tree structure that is stored in a single table. Let's say this is my model:
public class TreeNode {
public virtual Guid Id { get; private set; }
public virtual string Name { get; private set; }
public virtual IEnumerable<TreeNode> Contents { get; private set; }
}
and the table:
TREE_NODES
PK_NODE Guid
FK_NODE_PARENT Guid
NODE_NAME Varchar
I want the following implementation where the return value is a TreeNode with the full eagerly loaded tree of its children and their children, etc.
public class Tree {
ISessionFactory _sessions;
public TreeNode GetBy(Guid id) {
using(var s = _sessions.OpenSession())
return s.Linq<TreeNode>().Single(n => n.Id == id);
}
}
How would I do this mapping?