dapper分页存储过程

CREATE PROCEDURE  page_getperson
(
  _pageIndex INT,
  _pageSize INT,
  out _pagecount int
)
BEGIN

DECLARE startIndex int DEFAULT 0;
DECLARE tcount int DEFAULT 0;
set startIndex=(_pageIndex-1)*_pageSize;
SELECT * from Person LIMIT startIndex,_pageSize;
SELECT COUNT(id) into tcount from Person;
set _pagecount=tcount;

END

参数写法:

DynamicParameters param = new DynamicParameters();
  param.Add("_pageIndex", 2);
  param.Add("_pageSize", 5);
  param.Add("_pagecount", dbType: DbType.Int32, direction: ParameterDirection.Output);
  var result = mysql.FindToListByPage(connection, "page_getperson", param);
  //总条数
  var count = param.Get("_pagecount");
  var kk = result;

转载于:https://www.cnblogs.com/daoyi/articles/dapper-fen-ye-cun-chu-guo-cheng.html

你可能感兴趣的:(dapper分页存储过程)