using SqlSugar; using System; using System.Threading.Tasks; namespace GDZZ.Core; /// /// 分页拓展类 /// public static class PagedQueryableExtensions { /// /// 分页拓展 /// /// /// /// /// public static async Task> ToPagedListAsync(this ISugarQueryable query, int pageIndex, int pageSize) { RefAsync totalCount = 0; var items = await query.ToPageListAsync(pageIndex, pageSize, totalCount); var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize); return new SqlSugarPagedList { PageIndex = pageIndex, PageSize = pageSize, Items = items, TotalCount = (int)totalCount, TotalPages = totalPages, HasNextPages = pageIndex < totalPages, HasPrevPages = pageIndex - 1 > 0 }; } }