1
我在這裏與一個奇怪的行爲... 做一個與NHibernate作爲數據庫的ORM和MS SQL Server 2008的asp.net mvc3應用程序, m跑到這些exeption:NHibernate與SQL Server 2008方言不支持變量限制
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不支持這種簡單的分頁...
它確實工作得很好...出於某種原因,申請沒有感覺的話所做的更改(它曾經是MsSql2008Dialect)在配置文件中,直到我重新啓動Visual Studio。一旦重新啓動,問題消失 – themarcuz
我簽署了你的答案作爲冗餘建議的正確答案,即使你沒有提出一個通用含義的解決方案......但對我來說是恥辱,因爲沒有錯誤:) – themarcuz