NHibernate: can't successfully eager load

I'm using NH 3.0 and FNH 1.1 recompiled with NH3.

I have a user model where I want to always retrieve its profile when loading it. I use the linq provider from NH3 but can't use its Fetch method (because of my repository that hides NHibernate and returns an IQueryable and the fact that ToPagedList is called on the query therefore preventing me to put Fetch as the last call of the query).

In the UserMap I set:

HasOne(x => x.Profile)
    .Not.LazyLoad()
    .Cascade.All();

But setting LazyLoad to OFF does not help. I played with the fetch mode too.

My expectation is that if I define this mapping, then I should not even have to tell Linq that I want Profile to be fetched when the User entity is requested. Linq should honour the mapping, no?

8
задан Nicolas Cadilhac 8 December 2010 в 22:34
поделиться