当前位置:网站首页>Paging SQL
Paging SQL
2022-04-23 16:53:00 【Tassel 1990】
Paginated SQL, This method is requested once
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;
}
版权声明
本文为[Tassel 1990]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231359253968.html
边栏推荐
- Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
- The font of the soft cell changes color
- Knowledge points and examples of [seven input / output systems]
- 关于局域网如何组建介绍
- 建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
- RAID磁盘阵列与RAID5的创建
- Do you really understand the principle of code scanning login?
- Differences between MySQL BTREE index and hash index
- MySql主从复制
- Use case labeling mechanism of robot framework
猜你喜欢
Installation and management procedures
New project of OMNeT learning
feign报400处理
Nodejs reads the local JSON file through require. Unexpected token / in JSON at position appears
Nifi fast installation and file synchronization
Node access to Alipay open platform sandbox to achieve payment function
Do you really understand the principle of code scanning login?
磁盘管理与文件系统
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
随机推荐
org. apache. parquet. schema. InvalidSchemaException: A group type can not be empty. Parquet does not su
Quick install mongodb
博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
JMeter installation tutorial and solutions to the problems I encountered
Differences between MySQL BTREE index and hash index
如何建立 TikTok用户信任并拉动粉丝增长
Loading order of logback configuration file
Use case execution of robot framework
Set the color change of interlaced lines in cells in the sail software and the font becomes larger and red when the number is greater than 100
Talk about browser cache control
Gartner publie une étude sur les nouvelles technologies: un aperçu du métacosme
建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
RTKLIB 2.4.3源码笔记
Do you really understand the principle of code scanning login?
Calculate pie chart percentage
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
MySQL master-slave synchronization pit avoidance version tutorial
Installation and management procedures
PHP efficiently reads large files and processes data
Mock test using postman