Nhibernate QueryOver Orderby [英] Nhibernate QueryOver Orderby
本文介绍了Nhibernate QueryOver Orderby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 queryover 调用中解耦 orderby,但这无法编译
I'm trying to decouple the orderby on a queryover call and this doesn't compile
protected static void AddOrder<T>(IQueryOver<T, T> criteria, Expression<Func<object>> expression )
{
criteria.OrderBy(expression).Asc;
}
我猜有一种方法可以做到这一点,以某种方式将 asc 引入 linq 表达式?感谢您的帮助!
I'm guessing there is a way to do this, somehow bringing in the asc into the linq expression? Thanks for the help!
推荐答案
这不是 IQueryOver 的工作方式...要使其编译,您必须执行以下操作:
That's not how IQueryOver works... to make it compile, you'd have to do the following:
protected static IQueryOver<T, T> AddOrder<T>(IQueryOver<T, T> criteria,
Expression<Func<object>> expression)
{
return criteria.OrderBy(expression).Asc;
}
这没什么意义,因为它只是 OrderBy
的一个愚蠢的包装器.
Which makes little sense, as it's just a dumb wrapper for OrderBy
.
这篇关于Nhibernate QueryOver Orderby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文