How to pass multiple Expressions to OrderBy for EF?
问题 I am using EF 4.2, but I expect this would apply to EF 4 and 4.1 as well. I would like to pass an IQueryable<T> and multiple Expression<Func<TSource, TKey>> to a method and have the method apply OrderBy and ThenBy to the IQueryable<T> as appropriate. I found this answer, and wrote the method below based on that: public IQueryable<User> ApplyOrderBy(IQueryable<User> query, IEnumerable<Expression<Func<User, IComparable>>> orderBy) { if (orderBy == null) { return query; } IOrderedQueryable<User>