DAL分页

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;
        }
    }
}
上一篇:Android 注解处理器使用攻略


下一篇:[Erlang 0110] Erlang Abstract Format , Part 1