dapper sqlserver 分页

原文:dapper sqlserver 分页

sqlserver 2012及以后使用:

Copy
SELECT * FROM {TableName} ORDER BY {OrderBy} OFFSET 20 ROWS FETCH NEXT 5 ROWS ONLY

以前使用:

Copy
SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY {OrderBy}) AS PagedNumber, {SelectColumns} FROM {TableName} {WhereClause}) AS u WHERE PagedNumber BETWEEN (({PageNumber}-1) * {RowsPerPage} + 1) AND ({PageNumber} * {RowsPerPage})

参考:
https://github.com/ericdc1/Dapper.SimpleCRUD/blob/58fffc5b1eddcbf523ab033c46e9a594f662218a/Dapper.SimpleCRUD/SimpleCRUD.cs#L98
https://*.com/questions/9848592/dapper-paging
https://github.com/StackExchange/Dapper/issues/760#issuecomment-298302652

其他数据库:
https://dapper-tutorial.net/zh-CN/knowledge-base/5918384/

dapper sqlserver 分页

上一篇:[Unity3D]调用Android接口


下一篇:js正则匹配以固定格式结尾的字符串并匹配是手机访问,则跳转