代码修改

This commit is contained in:
he
2024-08-20 13:50:03 +08:00
parent 7194796841
commit 754da2c7fc
4 changed files with 4 additions and 51 deletions
@@ -149,54 +149,6 @@ namespace IRaCIS.Core.Infrastructure.Extention
}
//多字段排序异步 ["a asc", "b desc", "c asc"]
public static async Task<PageOutput<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageNumber, int pageSize, string[] sortArray)
{
if (pageNumber <= 0)
{
pageNumber = 1;
}
if (pageSize <= 0)
{
pageSize = 10;
}
var count = await source.CountAsync().ConfigureAwait(false);
if (count == 0)
{
return new PageOutput<T>() { CurrentPageData = new T[0] };
}
if(sortArray.Count()>0)
{
var sortString = string.Join(',', sortArray);
source = source.OrderBy(sortString);
}
source = source.Skip((pageNumber - 1) * pageSize);
var items = await source
.Take(pageSize)
.ToArrayAsync()
.ConfigureAwait(false);
var pagedList = new PageOutput<T>()
{
PageIndex = pageNumber,
PageSize = pageSize,
TotalCount = count,
CurrentPageData = items
};
return pagedList;
}
#region
////单字段排序
//public static PageOutput<T> ToPagedList<T>(this IQueryable<T> source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true)