精巧的人分页 [英] Dapper. Paging
本文介绍了精巧的人分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试Dapper ORM,并且正在查询Posts表.
I am trying Dapper ORM and I am querying a a Posts table.
但是我想获得分页结果...
But I would like to get paged results ...
1-我该怎么做?没有这个的帮手吗?
1 - How can I do this? Isn't there a helper for this?
2-Dapper Query可以返回IQueryable吗?
2 - Can Dapper Query return an IQueryable?
谢谢, 米格尔(Miguel)
Thank You, Miguel
推荐答案
1)Dapper没有内置的分页功能.但是直接在查询中实现它并不难.示例:
1) Dapper doesn't have a built-in pagination feature. But its not too hard to implement it directly in the query. Example:
SELECT *
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY InsertDate) AS RowNum, *
FROM Posts
WHERE InsertDate >= '1900-01-01'
) AS result
WHERE RowNum >= 1 // *your pagination parameters
AND RowNum < 20 //*
ORDER BY RowNum
需要SQL Server 2005 +
Requires SQL Server 2005+
2)Dapper返回IEnumerable<T>
.
2) Dapper returns an IEnumerable<T>
.
这篇关于精巧的人分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文