dapper sqlserver 分页

贵有恒,何必三更起、五更眠、最无益,只怕一日曝、十日寒。这篇文章主要讲述dapper sqlserver 分页相关的知识,希望能为你提供帮助。
原文:dapper sqlserver 分页sqlserver 2012及以后使用:

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

以前使用:
CopySELECT * 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
【dapper sqlserver 分页】其他数据库:
https://dapper-tutorial.net/zh-CN/knowledge-base/5918384/






    推荐阅读