mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update Oracle num 8,2 decimal? bug
This commit is contained in:
parent
18e37307b3
commit
33330ae31c
@ -13,6 +13,17 @@ namespace OrmTest
|
|||||||
if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false))
|
if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false))
|
||||||
Db.DbMaintenance.DropTable("UnitCodeTest1");
|
Db.DbMaintenance.DropTable("UnitCodeTest1");
|
||||||
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
||||||
|
Db.CodeFirst.InitTables<Unitasdfa1>();
|
||||||
|
Db.Insertable(new Unitasdfa1() { t1 = 1, t2 = 1 }).ExecuteCommand();
|
||||||
|
var x = Db.Queryable<Unitasdfa1>().ToList();
|
||||||
|
}
|
||||||
|
public class Unitasdfa1
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType = "number(8,2)")]
|
||||||
|
public decimal t2 { get; set; }
|
||||||
|
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType ="number(8,2)")]
|
||||||
|
public decimal? t1 { get; set; }
|
||||||
}
|
}
|
||||||
public class UnitCodeTest1
|
public class UnitCodeTest1
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ namespace SqlSugar
|
|||||||
private static readonly MethodInfo getInt32 = typeof(IDataRecord).GetMethod("GetInt32", new Type[] { typeof(int) });
|
private static readonly MethodInfo getInt32 = typeof(IDataRecord).GetMethod("GetInt32", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
|
private static readonly MethodInfo getInt64 = typeof(IDataRecord).GetMethod("GetInt64", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
|
private static readonly MethodInfo getString = typeof(IDataRecord).GetMethod("GetString", new Type[] { typeof(int) });
|
||||||
private static readonly MethodInfo getConvertValueMethod = typeof(IDataRecordExtensions).GetMethod("GetConvertValue");
|
//private static readonly MethodInfo getConvertValueMethod = typeof(IDataRecordExtensions).GetMethod("GetConvertValue");
|
||||||
private static readonly MethodInfo getdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("Getdatetimeoffset");
|
private static readonly MethodInfo getdatetimeoffset = typeof(IDataRecordExtensions).GetMethod("Getdatetimeoffset");
|
||||||
private static readonly MethodInfo getdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetdatetimeoffsetDate");
|
private static readonly MethodInfo getdatetimeoffsetDate = typeof(IDataRecordExtensions).GetMethod("GetdatetimeoffsetDate");
|
||||||
private static readonly MethodInfo getStringGuid = typeof(IDataRecordExtensions).GetMethod("GetStringGuid");
|
private static readonly MethodInfo getStringGuid = typeof(IDataRecordExtensions).GetMethod("GetStringGuid");
|
||||||
@ -223,7 +223,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (bindPropertyType == UtilConstants.StringType&&dbTypeName?.ToLower()== "timestamp")
|
else if (bindPropertyType == UtilConstants.StringType&&dbTypeName?.ToLower()== "timestamp")
|
||||||
{
|
{
|
||||||
method = getConvertValueMethod.MakeGenericMethod(columnInfo.PropertyInfo.PropertyType); ;
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
else if (bindPropertyType == UtilConstants.StringType)
|
else if (bindPropertyType == UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
@ -231,7 +231,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
method = getConvertValueMethod.MakeGenericMethod(columnInfo.PropertyInfo.PropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method.IsVirtual)
|
if (method.IsVirtual)
|
||||||
@ -301,11 +301,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (bindPropertyType == UtilConstants.DecType)
|
if (bindPropertyType == UtilConstants.DecType)
|
||||||
{
|
{
|
||||||
method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
if (bindPropertyType == UtilConstants.IntType)
|
if (bindPropertyType == UtilConstants.IntType)
|
||||||
{
|
{
|
||||||
method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.Guid:
|
case CSharpDataType.Guid:
|
||||||
@ -337,7 +337,7 @@ namespace SqlSugar
|
|||||||
case CSharpDataType.Single:
|
case CSharpDataType.Single:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (method == null && bindPropertyType == UtilConstants.StringType)
|
if (method == null && bindPropertyType == UtilConstants.StringType)
|
||||||
@ -346,7 +346,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (bindPropertyType == UtilConstants.ObjType)
|
if (bindPropertyType == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
method = getConvertValueMethod.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
if (method == null)
|
if (method == null)
|
||||||
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getOtherNull.MakeGenericMethod(bindPropertyType) : getOther.MakeGenericMethod(bindPropertyType);
|
||||||
|
@ -136,38 +136,22 @@ namespace SqlSugar
|
|||||||
var result = dr.GetInt32(i);
|
var result = dr.GetInt32(i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static T GetConvertValue<T>(this IDataRecord dr, int i)
|
//public static T GetConvertValue<T>(this IDataRecord dr, int i)
|
||||||
{
|
//{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (dr.IsDBNull(i))
|
// if (dr.IsDBNull(i))
|
||||||
{
|
// {
|
||||||
return default(T);
|
// return default(T);
|
||||||
}
|
// }
|
||||||
var result = dr.GetValue(i);
|
// var result = dr.GetValue(i);
|
||||||
return UtilMethods.To<T>(result);
|
// return UtilMethods.To<T>(result);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
if (dr.GetFieldType(i) == UtilConstants.DateType)
|
// return OtherException<T>(dr, i, ex);
|
||||||
{
|
// }
|
||||||
return UtilMethods.To<T>(dr.GetConvertDouble(i));
|
//}
|
||||||
}
|
|
||||||
if (dr.GetFieldType(i) == UtilConstants.GuidType)
|
|
||||||
{
|
|
||||||
var data = dr.GetString(i);
|
|
||||||
if (data.ToString() == "")
|
|
||||||
{
|
|
||||||
return UtilMethods.To<T>(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return UtilMethods.To<T>(Guid.Parse(data.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Exception(ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long? GetConvetInt64(this IDataRecord dr, int i)
|
public static long? GetConvetInt64(this IDataRecord dr, int i)
|
||||||
{
|
{
|
||||||
@ -264,19 +248,25 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var result = dr.GetValue(i);
|
return GetOther<T>(dr,i);
|
||||||
return UtilMethods.To<T>(result);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T GetOther<T>(this IDataReader dr, int i)
|
public static T GetOther<T>(this IDataReader 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)
|
||||||
|
{
|
||||||
|
return OtherException<T>(dr, i, ex);
|
||||||
}
|
}
|
||||||
var result = dr.GetValue(i);
|
|
||||||
return UtilMethods.To<T>(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T GetJson<T>(this IDataReader dr, int i)
|
public static T GetJson<T>(this IDataReader dr, int i)
|
||||||
@ -330,6 +320,28 @@ namespace SqlSugar
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static T OtherException<T>(IDataRecord dr, int i, Exception ex)
|
||||||
|
{
|
||||||
|
if (dr.GetFieldType(i) == UtilConstants.DateType)
|
||||||
|
{
|
||||||
|
return UtilMethods.To<T>(dr.GetConvertDouble(i));
|
||||||
|
}
|
||||||
|
if (dr.GetFieldType(i) == UtilConstants.GuidType)
|
||||||
|
{
|
||||||
|
var data = dr.GetString(i);
|
||||||
|
if (data.ToString() == "")
|
||||||
|
{
|
||||||
|
return UtilMethods.To<T>(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return UtilMethods.To<T>(Guid.Parse(data.ToString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Exception(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user