Nhibernate QueryOver Orderby

≯℡__Kan透↙ 提交于 2019-12-24 00:45:59

问题


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;
}

I'm guessing there is a way to do this, somehow bringing in the asc into the linq expression? Thanks for the help!


回答1:


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;
}

Which makes little sense, as it's just a dumb wrapper for OrderBy.



来源:https://stackoverflow.com/questions/3943777/nhibernate-queryover-orderby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!