• 通用存储过程定义


    using System;

    using System.Collections.Generic;

    using System.Data.SqlClient;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    using Model;

    using Model.DTO;

    using System.Data;

    using DB;

    using Newtonsoft.Json;

    namespace DAL

    {

        public class PageCommon

        {

            public static PageList<T> StoredList<T>(ParaModel model)

            {

                string sql = "up_CommodityFy";

                SqlParameter[] pars = new SqlParameter[7];

                pars[0] = new SqlParameter("@tableName", model.TableName);

                pars[1] = new SqlParameter("@indexCol", model.IndexCOl);

                pars[2] = new SqlParameter("@pageSize", model.PageSize);

                pars[3] = new SqlParameter("@pageIndex", model.PageIndex);

                pars[4] = new SqlParameter("@orderCol", model.OrderCol);

                pars[5] = new SqlParameter("@where", model.StrWhere);

                pars[6] = new SqlParameter("@columns", model.Columns);

                DataSet ds = DbHelperSQL.ExecuteDataset(DbHelperSQL.ConnB2c, CommandType.StoredProcedure, sql, pars);

                var list = JsonConvert.DeserializeObject<List<T>>(JsonConvert.SerializeObject(ds.Tables[0]));

                PageList<T> pagelist = new PageList<T>();

                pagelist.listData = list;

                //总条数

                int totalNum=    pagelist.TotalNum = Convert.ToInt32(ds.Tables[1].Rows[0][0]);

                //总页数

                int totalPage = (totalNum % model.PageSize) > 0 ? (totalNum / model.PageSize) + 1 : totalNum / model.PageSize;

             

                pagelist.TotalNum = totalNum;

                pagelist.TotalPage = totalPage;

                return pagelist;

            }

        }

    }

  • 相关阅读:
    关于Linux 上建立生成/添加SSH公钥
    sql随机插入数据--记录
    centos 安装搜狗
    centos yum命令找不到包
    命令行改为图形界面
    CentOS7l联网
    .net mvc 框架实现后台管理系统 3
    .net mvc 框架实现后台管理系统 2
    .net mvc 框架实现后台管理系统
    爬取猫眼数据
  • 原文地址:https://www.cnblogs.com/lockzy/p/9520343.html
Copyright © 2020-2023  润新知