Entity Framework 使用sql语句分页(查询视图)

时间:2022-11-17 06:13:58

1、查询视图

				//3、查询视图
var sql = @" SELECT D.*
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY TestView.B_MemberId ASC ) AS rownum ,
*
FROM TestView
) AS D
WHERE rownum BETWEEN ( @pageIndex - 1 ) * @pageSize + 1
AND @pageIndex * @pageSize
ORDER BY D.B_MemberId ASC";
object[] sqlParameter =
{
new SqlParameter("@pageIndex",pageIndex),
new SqlParameter("@pageSize",pageSize),
};
var list = dataaccess.QueryList<TestView>(sql, sqlParameter);