首页 > 其他 > 详细

DAL分页

时间:2018-08-22 21:40:02      阅读:175      评论:0      收藏:0      [点我收藏+]
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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!