Commit 855d3c1a authored by Marc Gravell's avatar Marc Gravell

Merge pull request #284 from Irrational86/master

SqlMapper global/default CommandTimeout
parents cb91e674 c645cb5f
......@@ -183,7 +183,13 @@ internal IDbCommand SetupCommand(IDbConnection cnn, Action<IDbCommand, object> p
cmd.Transaction = transaction;
cmd.CommandText = commandText;
if (commandTimeout.HasValue)
{
cmd.CommandTimeout = commandTimeout.Value;
}
else if (SqlMapper.Settings.CommandTimeout.HasValue)
{
cmd.CommandTimeout = SqlMapper.Settings.CommandTimeout.Value;
}
if (commandType.HasValue)
cmd.CommandType = commandType.Value;
if (paramReader != null)
......@@ -252,6 +258,30 @@ static MethodInfo GetBasicPropertySetter(Type declaringType, string name, Type e
/// </summary>
static partial class SqlMapper
{
/// <summary>
/// Permits specifying certain SqlMapper values globally.
/// </summary>
public static class Settings
{
static Settings()
{
SetDefaults();
}
/// <summary>
/// Resets all Settings to their default values
/// </summary>
public static void SetDefaults()
{
CommandTimeout = null;
}
/// <summary>
/// Specifies the default Command Timeout for all Queries
/// </summary>
public static int? CommandTimeout { get; set; }
}
/// <summary>
/// Implement this interface to pass an arbitrary db specific set of parameters to Dapper
/// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment