diff --git a/Dapper/SqlMapper.cs b/Dapper/SqlMapper.cs index 5575a6f5f..350b55cb3 100644 --- a/Dapper/SqlMapper.cs +++ b/Dapper/SqlMapper.cs @@ -446,8 +446,9 @@ public static void SetDbType(IDataParameter parameter, object value) { handler = null; var nullUnderlyingType = Nullable.GetUnderlyingType(type); - if (nullUnderlyingType is not null) type = nullUnderlyingType; - if (type.IsEnum && !typeMap.ContainsKey(type)) + + if (nullUnderlyingType is not null) type = nullUnderlyingType; + if (type.IsEnum && !typeMap.ContainsKey(type) && !typeHandlers.ContainsKey(type)) { type = Enum.GetUnderlyingType(type); }