当前位置:网站首页>分页SQL
分页SQL
2022-04-23 13:59:00 【流苏1990】
分页的SQL,这个方法就请求一次
public static StringBuilder SqlPageSql(string strSql, string orderField, bool isAsc, int pageSize, int pageIndex)
{
StringBuilder stringBuilder = new StringBuilder();
if (pageIndex <= 0)
pageIndex = 1;
string str = string.Empty;
if (string.IsNullOrEmpty(orderField) == false)
{
if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0)
str = " order by " + orderField;
else
str = " order by " + orderField + " " + (isAsc ? "asc" : "desc");
}
else
str = "order by (select 0)";
stringBuilder.Append("select * From (select row_number() Over (" + str + ")");
stringBuilder.Append(string.Concat(new object[] { " as rowNum,count(1) over() as totalRecord, * from (", strSql, ") T ) as N where rowNum > ", ((pageIndex - 1) * pageSize), " and rowNum <= ", (pageIndex * pageSize) }));
return stringBuilder;
}
版权声明
本文为[流苏1990]所创,转载请带上原文链接,感谢
https://blog.csdn.net/fuweiping/article/details/95633448
边栏推荐
- 2022年江西最新建筑八大员(质量员)模拟考试题库及答案解析
- groutine
- Leetcode? The first common node of two linked lists
- AttributeError: ‘dict‘ object has no attribute ‘iteritems‘
- China creates vast research infrastructure to support ambitious climate goals
- 村上春树 --《当我谈跑步时,我谈些什么》句子摘录
- The latest development of fed digital currency
- Analysis of unused index columns caused by implicit conversion of timestamp
- Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
- 【报名】TF54:工程师成长地图与卓越研发组织打造
猜你喜欢
随机推荐
Quartus Prime硬件实验开发(DE2-115板)实验一CPU指令运算器设计
Move blog to CSDN
Oracle alarm log alert Chinese trace and trace files
Pytorch 经典卷积神经网络 LeNet
scikit-learn構建模型的萬能模板
Small case of web login (including verification code login)
Leetcode | 38 appearance array
Business case | how to promote the activity of sports and health app users? It is enough to do these points well
Basic SQL query and learning
Program compilation and debugging learning record
Android篇:2019初中级Android开发社招面试解答(中
China creates vast research infrastructure to support ambitious climate goals
联想产品经理林林:天津当地网络运营商网络故障 ZUI系统后台服务器暂时无法正常工作
Express middleware ③ (custom Middleware)
Leetcode? The first common node of two linked lists
MySQL [acid + isolation level + redo log + undo log]
Haruki Murakami -- Excerpt from "what do I talk about when I talk about running"
JS brain burning interview question reward
项目中遇到的问题(五)操作Excel接口Poi的理解
Question bank and answer analysis of the 2022 simulated examination of the latest eight members of Jiangxi construction (quality control)