Reputation: 327
I have simple NHibernate Linq query (against MS SQL CE 4):
var productionStarts = (from p in session.Query<Production>()
orderby p.Start descending
select p.Start)
.Distinct()
.Take(maxProductionPlansPerOperation)
.ToArray();
which in NH 3.2.0.4000 throws exception:
System.NotSupportedException occurred
Message=Dialect does not support variable limits.
Source=NHibernate
StackTrace:
at NHibernate.Dialect.Dialect.GetLimitString(SqlString queryString, Nullable`1 offset, Nullable`1 limit, Parameter offsetParameter, Parameter limitParameter) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Dialect\Dialect.cs:line 1707
InnerException:
Problem is causing ".Take(...)". If commented out the query works.
It works fine with NH 3.1, but it no longer works NH 3.2.
In some older posts I found recommendation to use "MsSqlCe40Dialect", so I changed the dialect but no effect. I verified that NH is using correct dialect by examining properties of ISessionFactory instance.
Any suggestions how to fix this?
Upvotes: 2
Views: 1308
Reputation: 311
It is an error in the dialect, use this custom dialect to make it work:
public class FixedMsSqlCe40Dialect : MsSqlCe40Dialect
{
public override bool SupportsVariableLimit
{
get
{
return true;
}
}
}
Upvotes: 3