例如:
Func<IQueryable<Customers>, IOrderedQueryable<Customers>> orderBy = o => o.OrderBy(c => c.CustomerId).OrderByDescending(c => c.Level);
解析成
string sql = "order by CustomerId, Level desc";
用OrderBy..ThenBy:
.OrderByDescending(c => c.CustomerId)
.ThenByDescending(c => c.Level)
可以把所以的条件链接起来,应该也行
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> exprLeft,
Expression<Func<T, bool>> exprRight)
{
var invokedExpr = Expression.Invoke(exprRight, exprLeft.Parameters);
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(exprLeft.Body, invokedExpr), exprLeft.Parameters);
}