NHibernate - Where ISession.Query<T>() is located

五迷三道 提交于 2019-12-03 16:03:11

问题



When I try to compile the following code

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using NHibernate;

namespace NewNHTest
{
    class A
    { }

    class Program
    {
        static void Main(string[] args)
        {
            ISession session;
            var q = session.Query<A>();
        }
    }
}

I get the following error:

'NHibernate.ISession' does not contain a definition for 'Query' and no extension method 'Query' accepting a first argument of type 'NHibernate.ISession' could be found (are you missing a using directive or an assembly reference?)

NHibernate.dll version is 3.0.0.4000.
The .Net version of project is 3.5.

What am I doing wrong?
Thank you for your help!


回答1:


ISession.Query

is new to NHibernate 3 and is an extension method. Try

using NHibernate.Linq

and it should be resolved fine.



来源:https://stackoverflow.com/questions/4666665/nhibernate-where-isession-queryt-is-located

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!