C# SQL Database pagination using Dapper ORM

Database Pagination is something I have coded at every employer I have worked at. My approach has changed over the years, here is a look at how I would go about it now.

The requirements for this incarnation:

  • One database query should go across the wire, and we should both the Total Row Count as well as the Rows of the current page. Only the rows on a page should be returned from the database.
  • Support for querying ordering columns of more than one SQL type
  • SQL server database

Note the query uses offset and fetch clauses to limit the number of rows sent over the wire.

Things that will be improved shortly:

If you have any feedback please leave it on this blog or the GitHub Gist.

comments powered by Disqus