문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top