码迷,mamicode.com
首页 > 移动开发 > 详细

用Dapper调用存储过程

时间:2020-01-11 09:58:42      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:==   put   index   dapper   lis   type   pre   list()   add   

public PageModel Get(int PageIndex = 1, int PageSize = 5, int Pid = 0, int Tid = 0, int Gid = 0)
        {
            DynamicParameters sp = new DynamicParameters();
            sp.Add("@PageIndex", PageIndex);
            sp.Add("@PageSize", PageSize);
            sp.Add("@Pid", Pid);
            sp.Add("@Tid", Tid);
            sp.Add("@TotalCount", dbType: DbType.Int32, direction: ParameterDirection.Output);
            PageModel model = new PageModel()
            {
                data = conn.Query<GoodsModel>("G_Page", sp, commandType: CommandType.StoredProcedure).ToList(),
                TotalCount = sp.Get<int>("@TotalCount")
            };
            if (Gid!=0)
            {
               model.data= model.data.Where(s=>s.Gid==Gid).ToList();
            }
            return model;
        }

用Dapper调用存储过程

标签:==   put   index   dapper   lis   type   pre   list()   add   

原文地址:https://www.cnblogs.com/ly-03-04/p/12178908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!