using System; using System.Threading.Tasks; namespace SqlSugar { /// /// 分页拓展类 /// public static class PagedQueryableExtensions { /// /// 分页拓展 /// /// /// /// /// public static SqlSugarPagedList ToPagedList(this ISugarQueryable entity, int pageIndex, int pageSize) where TEntity : new() { var totalCount = 0; var items = entity.ToPageList(pageIndex, pageSize, ref totalCount); var pagination = new PagedModel() { PageIndex = pageIndex, PageSize = pageSize, Total = (int)totalCount }; return new SqlSugarPagedList { pagination = pagination, list = items }; } /// /// 分页拓展 /// /// /// /// /// public static async Task> ToPagedListAsync(this ISugarQueryable entity, int pageIndex, int pageSize) where TEntity : new() { RefAsync totalCount = 0; var items = await entity.ToPageListAsync(pageIndex, pageSize, totalCount); var pagination = new PagedModel() { PageIndex = pageIndex, PageSize = pageSize, Total = (int)totalCount }; return new SqlSugarPagedList { pagination = pagination, list = items }; } } }