1. 程式人生 > >DAL分頁顯示

DAL分頁顯示

str count columns ram int convert exec tab 分頁

public Pages<stuclass> GetStudetPage(PageParams pagePar)
{
int size = pagePar.PageSize;
string sql = "[dbo].[p_paging]";
SqlParameter[] par = new SqlParameter[]
{
new SqlParameter("@tableName", pagePar.TableName),
new SqlParameter("@indexCol", pagePar.IndexCol),
new SqlParameter("@pageSize", pagePar.PageSize),
new SqlParameter("@pageIndex", pagePar.PageIndex),
new SqlParameter("@orderCol", pagePar.OrderCol),
new SqlParameter("@where", pagePar.Where),
new SqlParameter("@columns", pagePar.Columns)
};
DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, sql, par);
DataTable dt = ds.Tables[0];
int count =Convert.ToInt32( ds.Tables[1].Rows[0] [0]);
Pages<stuclass> pagse = new Pages<stuclass>();
pagse.list = JsonConvert.DeserializeObject<List<stuclass>>(JsonConvert.SerializeObject(dt));
pagse.SumCount = count;
pagse.SumPage = (count % size > 0 ? ((count / size) + 1) : (count / size));
return pagse;
}

DAL分頁顯示