Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq for NHibernate and fetch mode of eager loading

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

like image 541
NabilS Avatar asked May 06 '09 21:05

NabilS


2 Answers

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

like image 197
Mike Hadlow Avatar answered Oct 09 '22 13:10

Mike Hadlow


just use it more then once.

IList<Entity> GetDataFromDatabase() {     var query = session.Linq<Entity>();     query.Expand("Property1");     query.Expand("Property2");     return query.ToList(); } 
like image 22
Paco Avatar answered Oct 09 '22 13:10

Paco