DAL分页
Posted bokeyuan259
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DAL分页相关的知识,希望对你有一定的参考价值。
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;
}
}
}
}
}
以上是关于DAL分页的主要内容,如果未能解决你的问题,请参考以下文章