Sqlsever time(7) to datetime bug

This commit is contained in:
sunkaixuan 2018-04-08 16:31:27 +08:00
parent ecf4bf0f72
commit d8983ce6a7
2 changed files with 17 additions and 0 deletions

View File

@ -49,6 +49,8 @@ namespace SqlSugar
private static readonly MethodInfo getConvertByte = typeof(IDataRecordExtensions).GetMethod("GetConvertByte");
private static readonly MethodInfo getConvertChar = typeof(IDataRecordExtensions).GetMethod("GetConvertChar");
private static readonly MethodInfo getConvertDateTime = typeof(IDataRecordExtensions).GetMethod("GetConvertDateTime");
private static readonly MethodInfo getConvertTime = typeof(IDataRecordExtensions).GetMethod("GetConvertTime");
private static readonly MethodInfo getTime = typeof(IDataRecordExtensions).GetMethod("GetTime");
private static readonly MethodInfo getConvertDecimal = typeof(IDataRecordExtensions).GetMethod("GetConvertDecimal");
private static readonly MethodInfo getConvertDouble = typeof(IDataRecordExtensions).GetMethod("GetConvertDouble");
private static readonly MethodInfo getConvertGuid = typeof(IDataRecordExtensions).GetMethod("GetConvertGuid");
@ -245,6 +247,8 @@ namespace SqlSugar
CheckType(bind.DateThrow, bindProperyTypeName, validPropertyName, propertyName);
if (bindProperyTypeName == "datetime")
method = isNullableType ? getConvertDateTime : getDateTime;
if (bindProperyTypeName == "datetime"&&dbTypeName == "time")
method = isNullableType ? getConvertTime : getTime;
break;
case CSharpDataType.@decimal:
CheckType(bind.DecimalThrow, bindProperyTypeName, validPropertyName, propertyName);

View File

@ -60,6 +60,19 @@ namespace SqlSugar
}
return result;
}
public static DateTime? GetConvertTime(this IDataRecord dr, int i)
{
var result = dr.GetValue(i);
if (result == DBNull.Value)
{
return null; ;
}
return Convert.ToDateTime(result.ToString());
}
public static DateTime GetTime(this IDataRecord dr, int i)
{
return Convert.ToDateTime(dr.GetValue(i).ToString());
}
public static decimal? GetConvertDecimal(this IDataRecord dr, int i)
{