Search code examples
c#nhibernatefluent-nhibernatequeryover

Is Query<> Obsolete in NHibernate 4.0 Version?


I am trying to use session.Query<> to query on my list but its not appearing on my intellisense. That's why I am using QueryOver instead:

using (ISession session = NHibernateSession.OpenSession())
{
    var customer = session.QueryOver<Customer>().List();
}

return View();

Is Query<> already obsolete?


Solution

  • A Query is an extension method:

    namespace NHibernate.Linq
    {
        public static class LinqExtensionMethods
        {
            public static IQueryable<T> Query<T>(this ISession session)
            {
                ...
    

    So, just be sure you have this statement in your C# file

    using NHibernate.Linq;