Eager load while using Linq in NHibernate 3?

Support for this went into the trunk sometime ago; the syntax is be something like var query = session.Query(). Fetch(p => p. Tags).

Where(bla bla); If Tags in turn had another relationship, you can do: var query = session.Query(). Fetch(p => p. Tags).

ThenFetch(t => t. SomethingElse). Where(bla bla).

3 Fetch must be placed after Where or you will get an exception. – Nicolas Cadilhac Dec 7 '10 at 18:36 @Nicolas Cadilhac, @Steve Strong - how do you add a where after a ThenFetch? Nicolas response says the above doesn't work but its the accepted answer so I am confused – leora Dec 30 '10 at 14:23 @Nicolas Cadilhac, @Steve Strong - When I run this, I get "notsupported Exception" – leora Dec 30 '10 at 14:52 @ooo: as you and I mentioned, Fetch and ThenFetch must be the last clause.

I accepted the answer knowing that I added a comment to tell about this constraint. In another SO question, I tried to know if there is a workaround (I need some Where clause after a fetch and paged result) but it seems the current status of LinqToNH does not allow it. So to answer your question, you can do it only with HQL or Criteria API.

Also I don't know why Linq does not honnor the lazy statement set in the mapping. – Nicolas Cadilhac Jan 6 at 15:14 @Nicolas Cadilhac -gotcha . .

Thanks – leora Jan 6 at 17:38.

It's not possible yet, but Steve Strong has planned to implement it.

Guess this is the answer then – LightX Jan 17 '10 at 12:49 this is a good news (can't find the evidence though). In that case, your answer will become the solution. – Nicolas Cadilhac Jan 6 at 15:16 @Nicolas Cadilhac: Huh?

This was posted a year ago and Steve Strongs answer is the answer. – Paco Jan 6 at 17:05 oops, seems like the change of year mixed me up. And didn't notice the name.Thx.

– Nicolas Cadilhac Jan 6 at 23:33.

For me this thread solve problem. stackoverflow.com/questions/1677301/linq... var linqsession = session.Linq(); linqsession.QueryOptions. RegisterCustomAction(c => c.

SetResultTransformer(new DistinctRootEntityResultTransformer())); var feedItemQuery = from ad in linqsession. Expand("Ads") where ad. Id == Id select ad.

There is no QueryOptions in Nbernate 3 – ILya Dec 23 '10 at 9:43.

Support for this went into the trunk sometime ago; the syntax is be something like.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions