Daniel Williams
Daniel Williams

Reputation: 9304

Where is session.Linq?

I see many examples of using Linq to NH like this:

ISession session = getSession();
    var query = from conference in session.Linq<Conference>()

But in my code there is no .Linq on ISession.

is the following Using not enough?

using NHibernate.Linq;

Upvotes: 1

Views: 607

Answers (1)

Miroslav Popovic
Miroslav Popovic

Reputation: 12128

You are importing the right namespace, but using the wrong method on ISession interface. Instead of ISession.Linq<T>(), use ISession.Query<T>().

ISession session = getSession();
var query = from conference in session.Query<Conference>()

ISession.Linq<T>() was a part of Linq 2 NHibernate, a separate project that was somewhat temporary solution. It was based on Criteria API. It's now obsolete.

The new NHibernate Linq provider is now a part of main NHibernate assembly (as of NH 3.0). It's based on HQL and has a lot more features.

Upvotes: 4

Related Questions