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
+7
A:
just use it more then once.
IList<Entity> GetDataFromDatabase()
{
var query = session.Linq<Entity>();
query.Expand("Property1");
query.Expand("Property2");
return query.ToList();
}
Paco
2009-05-06 23:57:20
or query.Expand("Property1,Property2");
Sprintstar
2009-08-20 09:53:03
Is that an expansion method? Can't find it in NHibernate.Linq v2.0.50727.
Arnis L.
2009-10-06 07:40:12
I mean, version 1.0.0.0
Arnis L.
2009-10-06 07:42:34
It is there, on NHibernate.Linq.Query<T>
liammclennan
2010-07-15 03:22:52
+5
A:
As far as I can see, this is not equivalent: SetFetchMode hydrates an objects tree and the Expand method retrieves a cartesian product.
Jeff
2009-09-20 20:23:24
+3
A:
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
Mike Hadlow
2010-08-06 11:22:07