Linq for NHibernate and fetch mode of eager loading

NabilS picture NabilS · May 6, 2009 · Viewed 20.3k times · Source

Is there a way to set the fetchmode to eager for more than one object using linq for nhibernate. There seems to be an expand method which only allows me to set one object. However I need to set it for more than one object. Is this possible? Thanks

Answer

Mike Hadlow picture Mike Hadlow · Aug 6, 2010

The new Linq provider does it a little differently:

var customers = session.Query<Customer>().Fetch(c => c.Orders).ToList();

More here: http://mikehadlow.blogspot.com/2010/08/nhibernate-linq-eager-fetching.html