当前位置:网站首页>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
边栏推荐
- Regular filtering of Intranet addresses and segments
- RAID磁盘阵列与RAID5的创建
- Set cell filling and ranking method according to the size of the value in the soft report
- loggie 源码分析 source file 模块主干分析
- TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
- 1959年高考数学真题
- 【题解】[SHOI2012] 随机树
- 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
- File system read and write performance test practice
- NVIDIA graphics card driver error
猜你喜欢

LVM与磁盘配额

OMNeT学习之新建工程

阿里研发三面,面试官一套组合拳让我当场懵逼

Gartner announces emerging technology research: insight into the meta universe

Idea of batch manufacturing test data, with source code

Sub database and sub table & shardingsphere

Project framework of robot framework

VLAN高级技术,VLAN聚合,超级Super VLAN ,Sub VLAN

On the security of key passing and digital signature

English | day15, 16 x sentence true research daily sentence (clause disconnection, modification)
随机推荐
聊一聊浏览器缓存控制
Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme
vim编辑器的实时操作
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
Differences between MySQL BTREE index and hash index
MySql主从复制
英语 | Day15、16 x 句句真研每日一句(从句断开、修饰)
Linux MySQL data timing dump
关于局域网如何组建介绍
计算饼状图百分比
NVIDIA显卡驱动报错
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
PostgreSQL列存与行存
◰ GL shadow map core steps
05 Lua control structure
Change the password after installing MySQL in Linux
磁盘管理与文件系统
蓝桥杯省一之路06——第十二届省赛真题第二场
1959年高考数学真题
How magical is the unsafe class used by all major frameworks?