public List<TEntity> FindList(Expression<Func<TEntity, bool>> predicate, Pagination pagination)
{
MovieSiteEntities db = new MovieSiteEntities();
pagination.records = db.Set<TEntity>().Where(predicate).Count(); bool isAsc = pagination.sord.ToLower() == "asc" ? true : false;
string[] _order = pagination.sidx.Split(',');
MethodCallExpression resultExp = null;
var tempData = dbcontext.Set<TEntity>().Where(predicate);
foreach (string item in _order)
{
string _orderPart = item;
_orderPart = Regex.Replace(_orderPart, @"\s+", " ");
string[] _orderArry = _orderPart.Split(' ');
string _orderField = _orderArry[0];
bool sort = isAsc;
if (_orderArry.Length == 2)
{
isAsc = _orderArry[1].ToUpper() == "ASC" ? true : false;
}
var parameter = Expression.Parameter(typeof(TEntity), "t");
var property = typeof(TEntity).GetProperty(_orderField);
var propertyAccess = Expression.MakeMemberAccess(parameter, property);
var orderByExp = Expression.Lambda(propertyAccess, parameter);
resultExp = Expression.Call(typeof(Queryable), isAsc ? "OrderBy" : "OrderByDescending", new Type[] { typeof(TEntity), property.PropertyType }, tempData.Expression, Expression.Quote(orderByExp));
} tempData = tempData.Provider.CreateQuery<TEntity>(resultExp);
//pagination.records = tempData.Count();
tempData = tempData.Skip<TEntity>(pagination.rows * (pagination.page - 1)).Take<TEntity>(pagination.rows).AsQueryable();
return tempData.ToList();
}

  

最新文章

  1. asp.net执行SqlServer存储过程!(详解!)
  2. js 获取当前的时间
  3. 数据库、数据表的创建SP2
  4. Linux中的SWAP交换分区
  5. Daily Scrum 10.25
  6. 双机相关知识(原理、LVM、Raid技术)
  7. 共享池之八:软解析、硬解析、软软解析 详解一条SQL在library cache中解析涉及的锁
  8. office在线预览方案
  9. 奔小康赚大钱(km)
  10. Mac最好的虚拟机软件Parallels,体验比Vmware棒
  11. 利用XAMPP本地搭建WordPress博客
  12. hibernate深度学习 游离状态 HQL
  13. Python——逻辑运算(or,and)
  14. Python迭代器与格式化
  15. 【转】非常实用的高频PCB电路设计70问
  16. 基于Spring-Cloud的微服务框架设计
  17. Optimization algorithm----Deep Learning
  18. js 中 0 和 null 、&quot;&quot; Boolean 值关系
  19. 342. Power of Four(One-line)
  20. 爬虫2.4-scrapy框架-图片分类下载

热门文章

  1. windows中eclipse连接虚拟机hdfs
  2. python基础--导入模块
  3. 简述前后端项目RSA+AES加解密
  4. 手把手带你发布Nuget包-图文说话
  5. python关键字以及含义,用法
  6. MSF魔鬼训练营-3.1.1信息收集-通过DNS和IP地址挖掘目标网络信息
  7. MyBatis Mapper XML 详解
  8. js中index()的四种经典用法(转https://blog.csdn.net/superit401/article/details/51726826)
  9. liunx 环境下安装 Eclipse C++
  10. 在springboot中集成jsp开发