public static class LinQHelper
{
public static IQueryableOrderByEx(this IQueryableq, string direction, string fieldName)
{
var param = Expression.Parameter(typeof(T), "p");
var prop = Expression.Property(param, fieldName);
var exp = Expression.Lambda(prop, param);
string method = direction.ToLower() == "asc" ? "OrderBy" : "OrderByDescending";
Type[] types = new Type[] { q.ElementType, exp.Body.Type };
var mce = Expression.Call(typeof(Queryable), method, types, q.Expression, exp);
return q.Pr
...
继续阅读
(21)