Browse Source

Special handling of drivers that cannot be resolved

pull/12/MERGE
skx 4 years ago
parent
commit
3a5d8fa605
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs
  2. 19
      Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataRecordExtensions.cs

4
Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataReaderEntityBuilder.cs

@ -217,6 +217,10 @@ namespace SqlSugar
{
method = isNullableType ? getConvertByte : getByte;
}
else if (bindPropertyType == UtilConstants.StringType&&dbTypeName?.ToLower()== "timestamp")
{
method = getConvertValueMethod.MakeGenericMethod(columnInfo.PropertyInfo.PropertyType); ;
}
else if (bindPropertyType == UtilConstants.StringType)
{
method = getString;

19
Src/Asp.Net/SqlSugar/Abstract/DbBindProvider/IDataRecordExtensions.cs

@ -138,12 +138,23 @@ namespace SqlSugar
}
public static T GetConvertValue<T>(this IDataRecord dr, int i)
{
if (dr.IsDBNull(i))
try
{
return default(T);
if (dr.IsDBNull(i))
{
return default(T);
}
var result = dr.GetValue(i);
return UtilMethods.To<T>(result);
}
catch (Exception ex)
{
if (dr.GetFieldType(i) == UtilConstants.DateType)
{
return UtilMethods.To<T>(dr.GetConvertDouble(i));
}
throw new Exception(ex.Message);
}
var result = dr.GetValue(i);
return UtilMethods.To<T>(result);
}
public static long? GetConvetInt64(this IDataRecord dr, int i)

Loading…
Cancel
Save