Synchronization code

This commit is contained in:
sunkaixuan
2023-12-27 12:22:16 +08:00
parent 515684c10d
commit 97b3d3affc

View File

@@ -504,6 +504,7 @@ namespace SqlSugar
addValue =UtilMethods.GetFormatValue(addValue,valueFomatInfo); addValue =UtilMethods.GetFormatValue(addValue,valueFomatInfo);
} }
var type = UtilMethods.GetUnderType(item.PropertyType);
if (addValue == DBNull.Value || addValue == null) if (addValue == DBNull.Value || addValue == null)
{ {
if (item.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.DecType, UtilConstants.DobType, UtilConstants.ByteType)) if (item.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.DecType, UtilConstants.DobType, UtilConstants.ByteType))
@@ -527,19 +528,19 @@ namespace SqlSugar
addValue = null; addValue = null;
} }
} }
else if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.IntType) else if (type == UtilConstants.IntType)
{ {
addValue = Convert.ToInt32(addValue); addValue = Convert.ToInt32(addValue);
} }
else if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.LongType) else if (type == UtilConstants.LongType)
{ {
addValue = Convert.ToInt64(addValue); addValue = Convert.ToInt64(addValue);
} }
else if (UtilMethods.GetUnderType(item.PropertyType).IsEnum() && addValue is decimal) else if (type.IsEnum() && addValue is decimal)
{ {
addValue = Convert.ToInt64(addValue); addValue = Convert.ToInt64(addValue);
} }
else if (item.PropertyType.FullName == "System.DateOnly") else if (type.FullName == "System.DateOnly")
{ {
addValue = Convert.ToDateTime(addValue).ToString("yyyy-MM-dd"); addValue = Convert.ToDateTime(addValue).ToString("yyyy-MM-dd");
} }