"select top (@limit) * from (select row_number() over(order by FId asc) as rownumber, * from T_Admin) temp_row where rownumber>(@offset-1) * @limit);";
public void GetUserList(HttpContext context)
{
int offset = Convert.ToInt32(context.Request["offset"]);
dynamic objJson = new ExpandoObject();
STKJ.BLL.T_Admin adminBLL = new STKJ.BLL.T_Admin();
int total = 0;
objJson.rows = adminBLL.GetUserList(limit,offset,out total);
objJson.total = total;
context.Response.Write(JsonConvert.SerializeObject(objJson));
}
然后再调用BLL的方法
public DataTable GetUserList(int limit, int offset,out int total)
{
return dal.GetUserList(limit, offset, out total);
}
最后再调用DAL方法
public DataTable GetUserList(int limit,int offset,out int total)
{
string sql = "select top (@limit) * from (select row_number() over(order by FId asc) as rownumber, * from T_Admin) temp_row where rownumber>(@offset-1) * @limit);";
string totalsql = "swlect COUNT(1) from T_Admin";
total = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.connStr, totalsql));
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@limit",SqlDbType.Int),
new SqlParameter("@offset",SqlDbType.Int)
};
para[0].Value = limit;
para[0].Value = offset;
return SqlHelper.ExecuteDataTable(SqlHelper.connStr, sql, para);
记得返回的数值
、
来源:博客园
作者:渔堂-net-王卫松
链接:https://www.cnblogs.com/yutang-wangweisong/p/11524118.html