我给了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做跳过.
原文链接:/vb/255741.htmlSELECT * 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