NHibernate-ISession.Query< T>()所在的位置
问题描述:
当我尝试编译以下代码时
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>();
}
}
}
我收到以下错误:
'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版本是3.0.0.4000.
该项目的.Net版本是3.5.
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!
答
ISession.Query
是NHibernate 3的新功能,是一种扩展方法. 试试
is new to NHibernate 3 and is an extension method. Try
using NHibernate.Linq
并且应该解决该问题.