v3.0.1
This commit is contained in:
橙子
2021-06-02 20:00:25 +08:00
parent 6ea91cbaf6
commit e5063e1a4d
57 changed files with 1665 additions and 359 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace CC.Yi.Common
{
public static class LinqHelper
{
//T是列表类型S是排序的属性
public static IQueryable GetPageEntities<T,S>(IQueryable<T> myData, int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda=null, Expression<Func<T, S>> orderByLambda=null, bool isAsc=false)
{
total = myData.Where(whereLambda).Count();
if (isAsc)
{
var pageData = myData.Where(whereLambda)
.OrderBy<T,S>(orderByLambda)
.Skip(pageSize * (pageIndex - 1))
.Take(pageSize).AsQueryable();
return pageData;
}
else
{
var pageData = myData.Where(whereLambda)
.OrderByDescending<T, S>(orderByLambda)
.Skip(pageSize * (pageIndex - 1))
.Take(pageSize).AsQueryable();
return pageData;
}
}
}
}