码迷,mamicode.com
首页 > 移动开发 > 详细

dapper sqlserver 分页

时间:2020-05-28 21:31:14      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:git   boa   htm   row   serve   imp   issues   change   tps   

原文: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://stackoverflow.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 分页

标签:git   boa   htm   row   serve   imp   issues   change   tps   

原文地址:https://www.cnblogs.com/lonelyxmas/p/12983763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!