标签:
public class PageListDto<T> { public int Count { get; set; } public List<T> Data { get; set; } }
public static PageListDto<T> GetPageList<T, S>(this IQueryable<T> source, int pageIndex, int pageSize, Expression<Func<T, S>> orderBy, bool isDESC = false) { Type type = typeof(T); PageListDto<T> result = new PageListDto<T>(); result.Count = source.Count(); if (isDESC) { result.Data = source.OrderByDescending(orderBy).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } else { result.Data = source.OrderBy(orderBy).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); } return result; }
var dwadw = db.Z_TagInfo.Where(p => p.Id > 1) .GetPageList(1, 10, p => p.Status);
标签:
原文地址:http://www.cnblogs.com/webShcool/p/5161108.html