using System;
using System.Collections.Generic;
using LModel.DTO;
using Newtonsoft.Json;
using System.Data.SqlClient;
using System.Data;
using DBHelper;
namespace DAL
{
public class PageCommon
{
public static PageInfo<T> GetPageInfo<T>(ParamModel model)
{
SqlParameter[] parms =
{
new SqlParameter("@tableName",model.tableName),
new SqlParameter("@indexCol",model.IndexCol),
new SqlParameter("@pageSize",model.PageSize),
new SqlParameter("@pageIndex",model.PageIndex),
new SqlParameter("@orderCol",model.OrderCol),
new SqlParameter("@where",model.StrWhere),
new SqlParameter("@columns",model.Columns),
};
///调用存储过程
DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c,CommandType.StoredProcedure, "p_paging",parms);
//转换类型
var list = JsonConvert.DeserializeObject<List<T>>(JsonConvert.SerializeObject(ds.Tables[0]));
//实例分页参数类
PageInfo<T> pageinfo = new PageInfo<T>();
pageinfo.listData = list;
pageinfo.tCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
return pageinfo;
}
}
}
DAL分页
原文:https://www.cnblogs.com/BoKeYuan259/p/9520308.html