Reputation: 2583
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...
Upvotes: 1
Views: 1367
Reputation: 52745
What version of NHibernate are you using? (latest is 3.2)
It works without problems for me.
Also, this is redundant:
(from agenzia in session.Query<Agenzia>() select agenzia)
It's equivalent to:
session.Query<Agenzia>()
Upvotes: 1