I am trying to get all the collections (non-Cartesian product) of the parent object, but I cannot figure out how to get the grandchildren. The structure of the table is as follows:

The following code gets my parents and his collections Child1 and Child2, as well as his collection ParentChild3, but I don’t know how to structure the query to get the grandchildren of Child3 (and defer them to Future ()).
var parent = _session
.QueryOver<Parent>()
.Where(x => x.Id == id)
.Future<User>();
var children1 =_session
.QueryOver<Parent>()
.Where(x => x.Id == id)
.Fetch(x => x.Children1).Eager
.Future<Parent>();
var children2 =_session
.QueryOver<Parent>()
.Where(x => x.Id == id)
.Fetch(x => x.Children2).Eager
.Future<Parent>();
var parentChildren3 =_session
.QueryOver<Parent>()
.Where(x => x.Id == id)
.Fetch(x => x.ParentChildren3).Eager
.Future<Parent>();
return parent.SingleOrDefault();
Semi-communication: is this the best way to get all the collections? Is it better (and possible) to use a query that gets the result using connections instead?
source
share