Auto-set SqlDbType.DateTime for DateTime parameters
Automatically assigns SqlDbType.DateTime to parameters when the value is a DateTime and no dbType is specified. This ensures correct SQL type mapping for DateTime values in stored procedures.
This commit is contained in:
@@ -19,6 +19,9 @@ internal sealed class StoredProcedureBuilder(string procedureName, string? retur
|
||||
_execSql.AppendLine($"{_separator}@{name} = @{name}");
|
||||
_separator = ',';
|
||||
|
||||
if (!dbType.HasValue && value is DateTime)
|
||||
dbType = SqlDbType.DateTime;
|
||||
|
||||
if (dbType.HasValue)
|
||||
_parameters.Add(new SqlParameter($"@{name}", dbType.Value) { Value = value });
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user