Yes ... just set the correct fetchmode.
I will turn on the example in a minute.
Example: from here =>
IList cats = sess.CreateCriteria(typeof(Cat)) .Add( Expression.Like("Name", "Fritz%") ) .SetFetchMode("Mate", FetchMode.Eager) .SetFetchMode("Kittens", FetchMode.Eager) .List();
You can specify whether you want to load child elements of the child too =>
.SetFetchMode("Kittens.BornOn", FetchMode.Eager)
If you are using Linq for NHibernate, use the Expand => method
var feedItemQuery = from ad in session.Linq<FeedItem>().Expand("Ads") where ad.Id == Id select ad;
And I would recommend using a helper method that creates a string from the lambda passed in the expression.
It is likely that you can specify Criteria for loading the entire tree. But I donβt know about it, and I prefer to indicate what I really need (it seems dangerous to download everything).
Does it help?
source share