调整的CommandTimeout在Dapper.NET? [英] Adjusting CommandTimeout in Dapper.NET?

查看:3171
本文介绍了调整的CommandTimeout在Dapper.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过存储过程通过小巧玲珑的运行SQL备份(我的应用程序的其余部分使用小巧精致,所以我倒是preFER继续通过它这一部分运行以及)。它工作得很好,直到将CommandTimeout踢

I'm trying to run SQL backups through a stored procedure through Dapper (the rest of my app uses Dapper so I'd prefer to keep this portion running through it as well). It works just fine until the CommandTimeout kicks in.

using (var c = SqlConnection(connstring))
{
    c.Open();
    var p = new DynamicParameters();
    // fill out p

    c.Execute("xp_backup_database", p, commandType: CommandType.StoredProcedure);
}

唯一的CommandTimeout设置我知道是的SqlCommand。有没有办法通过小巧玲珑的设置吗?

The only CommandTimeout setting I know of is in SqlCommand. Is there a way to set this via Dapper?

推荐答案

是的,有多个版本的执行功能。其中的一个(或更多)包含将CommandTimeout参数:

Yes, there are multiple versions of the Execute function. One (or more) of them contains the commandTimeout parameters:

public static int Execute(this IDbConnection cnn, string sql, dynamic param = null, IDbTransaction transaction = null, int? commandTimeout = null, CommandType? commandType = null)

从<一个拍摄href="https://github.com/StackExchange/dapper-dot-net/blob/master/Dapper%20NET40/SqlMapper.cs">SqlMapper.cs

这篇关于调整的CommandTimeout在Dapper.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆