1. 程式人生 > >加載分頁

加載分頁

esc out int parameter string ember count(0 != ext

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);
}

加載分頁