using System;
using System.Collections.Generic;
using LModel.DTO;
using Newtonsoft.Json;
using System.Data.SqlClient;
using System.Data;
using DBHelper;
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 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]));
{
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<T> pageinfo = new PageInfo<T>();
pageinfo.listData = list;
pageinfo.tCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
return pageinfo;
}
}
}
}
}