using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace t1_Back
{
class Program
{
static void Main(string[] args)
{
Heima90AEntities context = new Heima90AEntities();
// context
string s = "a";
Console.ReadKey();
}
static List<dynamic> GetPageList<T,TKey>(Expression<Func<T,dynamic>> select1,
Expression<Func<T,bool>> where,
Expression<Func<T,TKey>> order,int pageSize,
int pageIndex,out int total,bool isAsc)
where T:class
{
Heima90AEntities context = new Heima90AEntities();
total = context.Set<T>().Where(where).Count();
var result = context.Set<T>().Where(where);
if (isAsc)
{
result = result.OrderBy(order);
}
else
{
result = result.OrderByDescending(order);
}
return result.Skip((pageIndex-1)*pageSize).Take(pageSize).Select(select1).ToList();
}
}
}
EF
最新推荐文章于 2023-08-21 21:02:10 发布