【发布时间】:2011-12-03 14:56:49
【问题描述】:
我正在使用以下 c# 代码:
public IList<T> GetAllByExpression(Expression<Func<T, bool>> expression, int startIndex, int count, Func<T, DateTime> dateTimeSelector)
{
using (ISession session = NHibernateHelper.GetSession())
{
return session.Query<T>()
.Where(expression)
.OrderBy(dateTimeSelector)
.Skip(startIndex - 1)
.Take(count)
.ToList();
}
}
更新: 甚至下面的代码也会抛出同样的异常:
public IList<T> GetAllByExpression(Expression<Func<T, bool>> expression, int startIndex, int count, Expression<Func<T, DateTime>> dateTimeSelector)
{
using (ISession session = NHibernateHelper.GetSession())
{
return session.Query<T>()
.Where(expression)
//.OrderBy(dateTimeSelector)
//.Skip(startIndex - 1)
//.Take(count)
.ToList();
}
}
并得到 Nh 错误:
无法将“NHibernate.Hql.Ast.HqlCast”类型的对象转换为类型 'NHibernate.Hql.Ast.HqlBooleanExpression'。
我做错了什么?
【问题讨论】:
-
可能是您提供给失败的地方的表达式
标签: c# .net sql nhibernate