Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions Dapper/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ static Dapper.SqlMapper.SanitizeParameterValue(object? value) -> object!
static Dapper.SqlMapper.SetDbType(System.Data.IDataParameter! parameter, object! value) -> void
static Dapper.SqlMapper.Settings.ApplyNullValues.get -> bool
static Dapper.SqlMapper.Settings.ApplyNullValues.set -> void
static Dapper.SqlMapper.Settings.SupportLegacyParameterTokens.get -> bool
static Dapper.SqlMapper.Settings.SupportLegacyParameterTokens.set -> void
static Dapper.SqlMapper.Settings.CommandTimeout.get -> int?
static Dapper.SqlMapper.Settings.CommandTimeout.set -> void
static Dapper.SqlMapper.Settings.FetchSize.get -> long
Expand Down
7 changes: 7 additions & 0 deletions Dapper/SqlMapper.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ public static long FetchSize
}
}

/// <summary>
/// Indicates whether single-character parameter tokens (<c>?</c> etc) will be detected and used where possible;
/// this feature is not recommended and will be disabled by default in future versions;
/// where possible, prefer named parameters (<c>@yourParam</c> etc) or Dapper's "pseudo-positional" parameters (<c>?yourParam? etc</c>).
/// </summary>
public static bool SupportLegacyParameterTokens { get; set; } = true;

private static long s_FetchSize = -1;
}
}
Expand Down
6 changes: 4 additions & 2 deletions Dapper/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2532,11 +2532,13 @@ private static bool IsValueTuple(Type? type) => (type?.IsValueType == true
throw new NotSupportedException("ValueTuple should not be used for parameters - the language-level names are not available to use as parameter names, and it adds unnecessary boxing");
}

bool filterParams = false;
if (removeUnused && identity.commandType.GetValueOrDefault(CommandType.Text) == CommandType.Text)
bool filterParams = removeUnused && identity.commandType.GetValueOrDefault(CommandType.Text) == CommandType.Text;

if (Settings.SupportLegacyParameterTokens && filterParams)
{
filterParams = !smellsLikeOleDb.IsMatch(identity.sql);
}

var dm = new DynamicMethod("ParamInfo" + Guid.NewGuid().ToString(), null, new[] { typeof(IDbCommand), typeof(object) }, type, true);

var il = dm.GetILGenerator();
Expand Down