Dapper Contrib 输出参数
我正在研究 Dapper Contrib 存储过程,但我不知道如何从该过程中获取值输出参数。
这是我的存储过程:
ALTER PROCEDURE [dbo].[spCustomPaging]
@SkipCount INT,
@PageSize INT, /*record in 1 page*/
@TotalRows INT OUTPUT /*tong record*/
AS
BEGIN
SET NOCOUNT ON;
SELECT @TotalRows = COUNT(*)
FROM dbo.Product
SELECT *
FROM dbo.Product
ORDER BY ProductID
OFFSET @SkipCount ROW FETCH NEXT @PageSize ROWS ONLY
这是我的 Dapper contrib 查询:
db.Query<Models.Product>("spCustomPaging", new { SkipCount = skip, PageSize = pageSize }, commandType: System.Data.CommandType.StoredProcedure);
如何使用 Dapper Contrib 从存储过程中获取 TotalRow?
抱歉我的英语不好,谢谢。
I'm research about Dapper Contrib stored procedure and I don't know how to get value output parameter from the procedure.
This is my stored procedure:
ALTER PROCEDURE [dbo].[spCustomPaging]
@SkipCount INT,
@PageSize INT, /*record in 1 page*/
@TotalRows INT OUTPUT /*tong record*/
AS
BEGIN
SET NOCOUNT ON;
SELECT @TotalRows = COUNT(*)
FROM dbo.Product
SELECT *
FROM dbo.Product
ORDER BY ProductID
OFFSET @SkipCount ROW FETCH NEXT @PageSize ROWS ONLY
And this is my Dapper contrib query:
db.Query<Models.Product>("spCustomPaging", new { SkipCount = skip, PageSize = pageSize }, commandType: System.Data.CommandType.StoredProcedure);
How I can get the TotalRow from the stored procedure with Dapper Contrib?
Sorry for my bad English and thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用
DynamicParameters
作为可以为您想要输出的参数声明ParameterDirection.Output
的参数,然后我们可以使用Get;
获取输出值。You can try to use
DynamicParameters
be the parameter that can declareParameterDirection.Output
for the parameter which you want to be output, then we can useGet<int>
to get the output value.