Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Dapper NET40/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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>
Expand Down