diff --git a/Dapper/PublicAPI.Shipped.txt b/Dapper/PublicAPI.Shipped.txt index 4c5417a6..15f614f0 100644 --- a/Dapper/PublicAPI.Shipped.txt +++ b/Dapper/PublicAPI.Shipped.txt @@ -117,6 +117,7 @@ Dapper.SqlMapper.ICustomQueryParameter.AddParameter(System.Data.IDbCommand! comm Dapper.SqlMapper.Identity Dapper.SqlMapper.Identity.Equals(Dapper.SqlMapper.Identity? other) -> bool Dapper.SqlMapper.Identity.ForDynamicParameters(System.Type! type) -> Dapper.SqlMapper.Identity! +Dapper.SqlMapper.Identity.Identity(string! sql, System.Data.CommandType commandType, System.Data.IDbConnection! connection, System.Type? type, System.Type? parametersType) -> void Dapper.SqlMapper.IDynamicParameters Dapper.SqlMapper.IDynamicParameters.AddParameters(System.Data.IDbCommand! command, Dapper.SqlMapper.Identity! identity) -> void Dapper.SqlMapper.IMemberMap diff --git a/Dapper/SqlMapper.Identity.cs b/Dapper/SqlMapper.Identity.cs index 4871d9c0..f32f17ee 100644 --- a/Dapper/SqlMapper.Identity.cs +++ b/Dapper/SqlMapper.Identity.cs @@ -12,10 +12,10 @@ namespace Dapper private static readonly int s_typeHash; private static readonly int s_typeCount = CountNonTrivial(out s_typeHash); - internal Identity(string sql, CommandType? commandType, string connectionString, Type type, Type? parametersType, int gridIndex = 0) + internal Identity(string sql, CommandType commandType, string connectionString, Type type, Type? parametersType, int gridIndex = 0) : base(sql, commandType, connectionString, type, parametersType, s_typeHash, gridIndex) {} - internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type? parametersType, int gridIndex = 0) + internal Identity(string sql, CommandType commandType, IDbConnection connection, Type type, Type? parametersType, int gridIndex = 0) : base(sql, commandType, connection.ConnectionString, type, parametersType, s_typeHash, gridIndex) { } @@ -56,12 +56,12 @@ namespace Dapper private readonly Type[] _types; internal IdentityWithTypes(string sql, CommandType? commandType, string connectionString, Type type, Type? parametersType, Type[] otherTypes, int gridIndex = 0) - : base(sql, commandType, connectionString, type, parametersType, HashTypes(otherTypes), gridIndex) + : base(sql, commandType.GetValueOrDefault(), connectionString, type, parametersType, HashTypes(otherTypes), gridIndex) { _types = otherTypes ?? Type.EmptyTypes; } internal IdentityWithTypes(string sql, CommandType? commandType, IDbConnection connection, Type type, Type? parametersType, Type[] otherTypes, int gridIndex = 0) - : base(sql, commandType, connection.ConnectionString, type, parametersType, HashTypes(otherTypes), gridIndex) + : base(sql, commandType.GetValueOrDefault(), connection.ConnectionString, type, parametersType, HashTypes(otherTypes), gridIndex) { _types = otherTypes ?? Type.EmptyTypes; } @@ -95,14 +95,14 @@ namespace Dapper #pragma warning disable CS0618 // Type or member is obsolete internal Identity ForGrid(Type primaryType, int gridIndex) => - new Identity(sql, commandType, connectionString, primaryType, parametersType, gridIndex); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, gridIndex); internal Identity ForGrid(Type primaryType, int gridIndex) => - new Identity(sql, commandType, connectionString, primaryType, parametersType, 0, gridIndex); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, 0, gridIndex); internal Identity ForGrid(Type primaryType, Type[] otherTypes, int gridIndex) => (otherTypes is null || otherTypes.Length == 0) - ? new Identity(sql, commandType, connectionString, primaryType, parametersType, 0, gridIndex) + ? new Identity(sql, commandType.GetValueOrDefault(), connectionString, primaryType, parametersType, 0, gridIndex) : new IdentityWithTypes(sql, commandType, connectionString, primaryType, parametersType, otherTypes, gridIndex); /// @@ -111,13 +111,17 @@ namespace Dapper /// The parameters type to create an for. /// public Identity ForDynamicParameters(Type type) => - new Identity(sql, commandType, connectionString, this.type, type, 0, -1); + new Identity(sql, commandType.GetValueOrDefault(), connectionString, this.type, type, 0, -1); #pragma warning restore CS0618 // Type or member is obsolete - internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type? type, Type? parametersType) + /// + /// Create a new instance. + /// + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] // discourage usage + public Identity(string sql, CommandType commandType, IDbConnection connection, Type? type, Type? parametersType) : this(sql, commandType, connection.ConnectionString, type, parametersType, 0, 0) { /* base call */ } - private protected Identity(string sql, CommandType? commandType, string connectionString, Type? type, Type? parametersType, int otherTypesHash, int gridIndex) + private protected Identity(string sql, CommandType commandType, string connectionString, Type? type, Type? parametersType, int otherTypesHash, int gridIndex) { #pragma warning disable CS0618 // Type or member is obsolete this.sql = sql; @@ -165,7 +169,7 @@ namespace Dapper /// [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Please use " + nameof(CommandType) + ". This API may be removed at a later date.")] - public readonly CommandType? commandType; + public readonly CommandType? commandType; // in addition to field hell, this should now be non-nullable /// /// The SQL command type.