Skip to content

Commit

Permalink
DbCommandExtension also complements the fallback processing of DbType.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliex committed Jan 2, 2021
1 parent 4f64ab6 commit aea430a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions RepoDb.Core/RepoDb/Extensions/DbCommandExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ private static void CreateParametersInternal(IDbCommand command,
classProperty.GetDbType() ??
value?.GetType()?.GetDbType();

// Try get fallback dbType by classProperty to avoid being mistaken as string when value is null.
if (dbType == null && classProperty != null)
{
dbType = clientTypeToDbTypeResolver.Resolve(classProperty.PropertyInfo.PropertyType);
}

// Specialized enum
if (dbType == null && isEnum.HasValue && isEnum.Value == true)
{
Expand Down Expand Up @@ -334,6 +340,12 @@ private static void CreateParameters(IDbCommand command,
classProperty?.GetDbType() ??
value?.GetType()?.GetDbType();

// Try get fallback dbType by classProperty to avoid being mistaken as string when value is null.
if (dbType == null && classProperty != null)
{
dbType = clientTypeToDbTypeResolver.Resolve(classProperty.PropertyInfo.PropertyType);
}

// Specialized enum
if (dbType == null && isEnum.HasValue && isEnum.Value == true)
{
Expand Down Expand Up @@ -463,6 +475,12 @@ private static void CreateParameters(this IDbCommand command,
classProperty?.GetDbType() ??
value?.GetType()?.GetDbType();

// Try get fallback dbType by classProperty to avoid being mistaken as string when value is null.
if (dbType == null && classProperty != null)
{
dbType = clientTypeToDbTypeResolver.Resolve(classProperty.PropertyInfo.PropertyType);
}

// Specialized enum
if (dbType == null && isEnum.HasValue && isEnum == true)
{
Expand Down

0 comments on commit aea430a

Please sign in to comment.