NHibernate 3.0 LINQ fetch question

213 views
Skip to first unread message

Dmitry

unread,
Dec 24, 2010, 7:25:51 PM12/24/10
to nhibernate-development
Fetch method in LINQ only seems to work if there is no select clause
statement.

"session.Query<Company>().Fetch(c => c.Employees).ToList()" works
fine.

However:

"session.Query<Company>().Fetch(c => c.Employees).Select(c =>
c).ToList()" which is the same as
"(from comp in session.Query<Company>().Fetch(c => c.Employees) select
comp).ToList()" throws a NotSupported exception.

This means you cannot have Fetch in any non-trivial queries.

Is this a known issue or I am doing something wrong? Entities are
simple and are mapped using camel-case fields.

Dmitry

unread,
Dec 24, 2010, 7:42:16 PM12/24/10
to nhibernate-development
I got it. It should have been

(from comp in session.Query<Company>() select comp).Fetch(c =>
c.Employees).ToList()

It was not obvious to me because I am used to Entity Framework where
it works the other way.
Reply all
Reply to author
Forward
0 new messages