using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BasicProduct.Model.DTO;
using BasicProduct.DB;
using Newtonsoft.Json;
namespace BasicProductSqlserver.DAL
{
public class PageCommon
{
///
/// 列表分页
///
///
///
///
public static PageList GetPagedListData(ParamModel model)
{
SqlParameter[] prms = new SqlParameter[7];
prms[0] = new SqlParameter(“@tableName”, model.TableName);
prms[1] = new SqlParameter(“@indexCol”, model.IndexCol);
prms[2] = new SqlParameter(“@pageSize”, model.PageSize);
prms[3] = new SqlParameter(“@pageIndex”, model.PageIndex);
prms[4] = new SqlParameter(“@orderCol”, model.OrderCol);
prms[5] = new SqlParameter(“@where”, model.StrWhere);
prms[6] = new SqlParameter(“@columns”, model.Columns);
DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, "p_paging", prms);
var list = JsonConvert.DeserializeObject<List<T>>(JsonConvert.SerializeObject(ds.Tables[0]));
PageList<T> pageList = new PageList<T>();
pageList.listData = list;
pageList.TotalNum = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
return pageList;
}
}
}