NHibernate 与 sql Server 2008 方言不支持变量限制
我在这里与一种奇怪的行为作斗争...... 使用 NHibernate 作为 ORM 和 MS SQL Server 2008 作为 DB 做一个 asp.net mvc3 应用程序,我遇到了这些例外:
System.NotSupportedException: Dialect does not support variable limits.
代码非常简单,一个经典的分页查询:
public IList<Agenzia> getAllAgenzie(int maximumRows, int startRowIndex)
{
using (var session = PersistenceManager.Istance.GetSession()) {
var result = (from agenzia in session.Query<Agenzia>()
select agenzia)
.Skip(startRowIndex)
.Take(maximumRows)
.ToList();
return result;
}
}
这是 NHibernate 配置
<?xml version="1.0" encoding="utf-8" ?>
<!-- NHibernate Configuration -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="NHibernate.xlns">
<property name="dialect">
NHibernate.Dialect.MsSql2008Dialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
知道它出了什么问题吗?我不敢相信 NHibernate 不支持这种简单的分页......
I'm fighting with a strange behavior here...
Doing an asp.net mvc3 application with NHibernate as ORM and MS SQL Server 2008 as the DB, I'm running into these exeption:
System.NotSupportedException: Dialect does not support variable limits.
The code is pretty simple, a classic pagination query:
public IList<Agenzia> getAllAgenzie(int maximumRows, int startRowIndex)
{
using (var session = PersistenceManager.Istance.GetSession()) {
var result = (from agenzia in session.Query<Agenzia>()
select agenzia)
.Skip(startRowIndex)
.Take(maximumRows)
.ToList();
return result;
}
}
And here's the NHibernate configuration
<?xml version="1.0" encoding="utf-8" ?>
<!-- NHibernate Configuration -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="NHibernate.xlns">
<property name="dialect">
NHibernate.Dialect.MsSql2008Dialect
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Any idea what's wrong with it? I can't believe that NHibernate don't support this simple pagination...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用什么版本的 NHibernate? (最新的是 3.2)
它对我来说没有问题。
另外,这是多余的:
它相当于:
What version of NHibernate are you using? (latest is 3.2)
It works without problems for me.
Also, this is redundant:
It's equivalent to: