I have seen similar answers for questions where you have a single entity and want to load all of its collections using multiple queries (instead of a large set of joins):
NHibernate Multiquery for eager loading without joins
My question is, how do you do a similar thing when the starting point for the query is a LIST of entities.
Details
Types: ContainerType, CollectionType1, CollectionType2, CollectionType[3....10]
ContainerType {
List<CollectionType1> collection;
List<CollectionType2> collection2;
}
CollectionType1 {
List<CollectionType1> childCollection;
List<CollectionType3> childCollection3;
...
List<CollectionType10> childCollection10;
}
What I want to avoid
List<ContainerType> containers = new Session.Linq<ContainerType>()
.FetchMany(container => container.collection)
.ThenFetchMany(collection => collection.childCollection)
.FetchMany(container => container.collection2)
.ToList();
Is there a way to use multiquery/multicriteria to set up these joins assuming I don't have a single Id I can relate them all to?
How I finally got it working as desired
Session.Linq<ContainerType>
.FetchMany(container => container.CollectionType1s)
.ToList();
Session.Linq<CollectionType1>
.FetchMany(parent => parent.Children)
.ToList();
Session.Linq<CollectionType1>
.FetchMany(allType1s => allType1s.CollectionType3)
.ThenFetchMany(type3 => type3.CollectionType3_1) // etc.
// etc.
.ToList();
// etc.
List<ContainerType> containers = Session.Linq<ContainerType>()
.ToList();