当前位置:网站首页>关于EF翻页查询数据库
关于EF翻页查询数据库
2022-06-25 22:44:00 【应用猎人】
1./// <summary>
/// 翻页查询
/// </summary>
/// <typeparam name="Tkey"></typeparam>
/// <param name="pageSize">每页大小</param>
/// <param name="pageIndex">第几页</param>
/// <param name="total">总数</param>
/// <param name="whereLambda">查询条件</param>
/// <param name="orderbyLambda">排序条件</param>
/// <param name="isAsc">是否升序</param>
/// <returns></returns>
public IQueryable<T> LoadPageItems<Tkey>(int pageSize, int pageIndex, out int total, Expression<Func<T, bool>> whereLambda, Func<T, Tkey> orderbyLambda, bool isAsc)
{
total = Entities.Where(whereLambda).Count();
if (isAsc)
{
var temp = Entities.Where(whereLambda).OrderBy<T, Tkey>(orderbyLambda)
.Skip(pageSize * (pageIndex - 1))
.Take(pageSize);
return temp.AsQueryable();
}
else
{
var temp = Entities.Where(whereLambda).OrderByDescending<T, Tkey>(orderbyLambda)
.Skip(pageSize * (pageIndex - 1))
.Take(pageSize);
return temp.AsQueryable();
}
}
边栏推荐
- 【超能云终端创领先机】如何在48小时内交付一座方舱医院?
- Compile the telegraph desktop side (tdesktop) using vs2022
- 1-11Vmware虚拟机常见的问题解决
- Typescript for Web Learning
- 【TSP问题】基于Hopfield神经网络求解旅行商问题附Matlab代码
- 11.1.2 overview of Flink_ Wordcount case
- ciscn_ 2019_ en_ two
- [image detection] vascular tracking and diameter estimation based on Gaussian process and Radon transform with matlab code
- jarvisoj_ level2_ x64
- 机器视觉:照亮“智”造新“视”界
猜你喜欢
统一网关Gateway
下载安装Flume
How to deliver a shelter hospital within 48 hours?
Preorder and middle order traversal of forest
The development context of Ba Kong Yuan universe industry
QT excellent open source project 9: qtox
Electronic training.
Installation and configuration of gradle environment
Vscode shortcut
Camkiia et gcamp6f sont - ils les mêmes?
随机推荐
学习识别对话式问答中的后续问题
ciscn_ 2019_ en_ two
机器视觉:照亮“智”造新“视”界
Function and principle of SPI solder paste inspection machine
Redisson 3.17.4 发布
Analysis and comparison of common test methods for PCBA in SMT chip processing industry
Unified gateway
Is camkiia the same as gcamp6f?
jarvisoj_level2_x64
Leetcode 513. Find the value in the lower left corner of the tree
Binary sort tree
sqlserver 区分字符串中字母大小写
How to design the product roadmap?
. user. PHP website installation problems caused by INI files
随便画画的
Apache foundation officially announced Apache inlong as a top-level project
使用VS2022编译Telegram桌面端(tdesktop)
mongodb
DPVS fullnat mode management
jarvisoj_ level2_ x64