其他分享
首页 > 其他分享> > Api 存储过程分页

Api 存储过程分页

作者:互联网

 //分页
        [Route("api/pager")]
        [HttpGet]
        public IHttpActionResult Pager(int PageSize, int PageIndex)
        {
            IDbConnection db = AbsContention.SqlGet();
            var param = new DynamicParameters();
            param.Add("@TabeName", "LogType");
            param.Add("@FileName", "*");
            param.Add("@Orderby", "ID");
            param.Add("@where", "");
            param.Add("@PageSize", PageSize);
            param.Add("@PageIndex", PageIndex);
            int total = 0;
            param.Add("@TableCount", 0, DbType.Int32, ParameterDirection.Output);
            //  db.Query<List<StudentModels>>("Proc_Pager",)
            var res2 = db.Query<LogModel>("FenYe", param, null, true, null, CommandType.StoredProcedure).ToList();//res2.Count = 80
            total = param.Get<int>("@TableCount");  //Execute count = 80
            return Ok(new { data = res2, total = total });
        }

标签:存储,分页,PageSize,int,param,res2,Add,Api,total
来源: https://www.cnblogs.com/GuoLianSheng/p/13259344.html