1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace gpt_api.Core.Extensions
- {
- /// <summary>
- /// 分页扩展
- /// </summary>
- public static class PagedQueryableExtension
- {
- /// <summary>
- /// 获取分页列表
- /// </summary>
- /// <param name="query"></param>
- /// <param name="page"></param>
- /// <returns></returns>
- public static async Task<PagedList<TEntity>> ToPagedListAsync<TEntity>(this ISugarQueryable<TEntity> query, PagedInput page)
- {
- RefAsync<int> count = 0;
- List<TEntity> result = await query.ToPageListAsync(page.PageIndex, page.PageSize, count);
- return new PagedList<TEntity>
- {
- TotalCount = count.Value,
- List = result
- };
- }
- }
- }
|