Eager loading a tree in NHibernate
I have a problem trying to load a tree, this is my case, I have an entity associated with itself (Hierarchic) with n levels; the question is, Can I load eagerly the entire tree using ICriteria or HQL? Thanks in advance for any help. Ariel Yes... just set correct fetchmode. i'll include example in a minute. Example taken 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 to eager load child of child too => .SetFetchMode("Kittens.BornOn",