加载分页
Posted 六月雨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了加载分页相关的知识,希望对你有一定的参考价值。
public List<Customer> LoadPage(string where, int index, int size, out int total, List<DbParameter> args) {
List<DbParameter> ps = new List<DbParameter>();
ps.AddRange(args);
string sql = @"SELECT COUNT(0) as total FROM [dbo].[Customer] WHERE [member_id] != ‘‘ " + where;
total = Convert.ToInt32(database.ExecuteScalar(sql, ps));
sql = @"
SELECT
*
FROM
[dbo].[Customer]
WHERE
[member_id] != ‘‘
" + where + @"
ORDER BY ID DESC
OFFSET @p ROWS FETCH NEXT @pz ROWS ONLY";
List<DbParameter> ps1 = new List<DbParameter>();
ps1.AddRange(args);
ps1.Add(new SqlParameter("@p", (index - 1) * size));
ps1.Add(new SqlParameter("@pz", size));
return database.ExecuteReader<Customer>(sql, ps1);
}
以上是关于加载分页的主要内容,如果未能解决你的问题,请参考以下文章