当前位置:网站首页>分页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
边栏推荐
猜你喜欢
Choreographer full resolution
JUC interview questions about synchronized, ThreadLocal, thread pool and atomic atomic classes
Express②(路由)
【vmware】vmware tools 地址
Solution of discarding evaluate function in surprise Library
scikit-learn構建模型的萬能模板
groutine
What is the difference between blue-green publishing, rolling publishing and gray publishing?
Three characteristics of volatile keyword [data visibility, prohibition of instruction rearrangement and no guarantee of operation atomicity]
Special test 05 · double integral [Li Yanfang's whole class]
随机推荐
Tensorflow Download
cnpm的诡异bug
FDFS start
Android篇:2019初中级Android开发社招面试解答(中
基础知识学习记录
美联储数字货币最新进展
leetcode--380.O(1) 时间插入、删除和获取随机元素
Using Baidu Intelligent Cloud face detection interface to achieve photo quality detection
New关键字的学习和总结
STM32学习记录0007——新建工程(基于寄存器版)
Express ② (routing)
Oracle RAC database instance startup exception analysis IPC send timeout
程序编译调试学习记录
[code analysis (6)] communication efficient learning of deep networks from decentralized data
[code analysis (4)] communication efficient learning of deep networks from decentralized data
1256:献给阿尔吉侬的花束
UNIX final exam summary -- for direct Department
UML Unified Modeling Language
scikit-learn构建模型的万能模板
Express②(路由)