diff --git a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs index 041a7bebe..32351f118 100644 --- a/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs +++ b/Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs @@ -504,6 +504,7 @@ namespace SqlSugar addValue =UtilMethods.GetFormatValue(addValue,valueFomatInfo); } + var type = UtilMethods.GetUnderType(item.PropertyType); if (addValue == DBNull.Value || addValue == null) { if (item.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.DecType, UtilConstants.DobType, UtilConstants.ByteType)) @@ -527,18 +528,22 @@ namespace SqlSugar addValue = null; } } - else if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.IntType) + else if (type == UtilConstants.IntType) { addValue = Convert.ToInt32(addValue); } - else if (UtilMethods.GetUnderType(item.PropertyType) == UtilConstants.LongType) + else if (type == UtilConstants.LongType) { 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); } + else if (type.FullName == "System.DateOnly") + { + addValue = Convert.ToDateTime(addValue).ToString("yyyy-MM-dd"); + } result.Add(name, addValue); } }