vb.net – Dapper ORM分页和排序

前端之家收集整理的这篇文章主要介绍了vb.net – Dapper ORM分页和排序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我给了Dapper ORM一个尝试.我可以使用以下代码从表查询数据:
Dim comments As List(Of Comment)
Using conn = New sqlConnection(ConnectionString)
    conn.Open()
    comments = conn.Query(Of Comment)("SELECT * from comments where userid = @commentid",New With {.userid= 1})
End Using

Return View(comments)

我有兴趣了解如何使用Dapper进行分页/排序. EF有“跳过”和“采取”来帮助这个.我知道一个微型ORM没有内置的,但想知道最好的方式来完成这个.

如果你想和Dapper,you do it with T-SQL做跳过.
SELECT *
FROM
(
SELECT tbl.*,ROW_NUMBER() OVER (ORDER BY ID) rownum
FROM comments as tbl
) seq
 WHERE seq.rownum BETWEEN @x AND @y
 AND userid = @commentid
 ORDER BY seq.rownum
原文链接:https://www.f2er.com/vb/255741.html

猜你在找的VB相关文章