Question: Given an NHibernate entity Parent, is there any way to get a LINQ query on a Children collection to execute on the database side rather than lazy-loading all the children and then performing the query?
Scenario:
Parent object has IList collection (Children)
var parent = _parentRepository.Get(parentId); //loads parent
..do stuff
//this causes all Child objects to be loaded into memory
//and then finds the subset of boy objects (not great performance)
var boys = parent.Children.Where(t => t.Sex == 1);
If I try explicitly passing an Expression<Func<Child, bool>>, I get an error that it's expecting a type Func<Child, bool>.
Is there any way to get more efficient lazy loading w/NHibernate?
Thanks!