日期:2014-05-20 浏览次数:20850 次
public PagedList<T> GetManyPage(QueryModel query,PageSelect pageSel) { Type type = typeof(T); var key = type.GetProperty(pageSel.OrderByKey); ParameterExpression param = Expression.Parameter(typeof(T), "c"); MemberExpression paramKey = Expression.Property(param, pageSel.OrderByKey); //var expression = Expression.Lambda<Func<T, TKey>>(paramKey, param); if (pageSel.Direction == Direction.asc) { //return dbset.Where(query).OrderBy(c => pageSel.OrderByKey).ToPagedList(pageSel.CurrentPage, pageSel.PageSize); return dbset.Where(query).OrderBy(c => key).ToPagedList(pageSel.CurrentPage, pageSel.PageSize); //return dbset.Where(query).OrderByDescending(c => key).ToPagedList(pageSel.CurrentPage, pageSel.PageSize); } return dbset.Where(query).OrderByDescending(c => pageSel.OrderByKey).ToPagedList(pageSel.CurrentPage, pageSel.PageSize); }