diff --git a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs index e5a82bf33..57896ca2a 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs @@ -177,6 +177,10 @@ namespace SqlSugar { item[col.ColumnName] = string.Empty; } + else if (col.DataType == UtilConstants.DateType) + { + item[col.ColumnName] =UtilMethods.GetMinDate(this.context.CurrentConnectionConfig); + } else { item[col.ColumnName] = Activator.CreateInstance(col.DataType); diff --git a/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs b/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs index a1aba4a90..927cf1077 100644 --- a/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs +++ b/Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs @@ -14,6 +14,7 @@ namespace SqlSugar public bool DisableMillisecond { get; set; } public bool PgSqlIsAutoToLower = true; public int DefaultCacheDurationInSeconds { get; set; } - public bool? TableEnumIsString { get; set; } + public bool? TableEnumIsString { get; set; } + public DateTime? DbMinDate { get; set; } = Convert.ToDateTime("1900-01-01"); } } diff --git a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs index ee08af296..0d4784938 100644 --- a/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs +++ b/Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs @@ -193,6 +193,23 @@ namespace SqlSugar { return (T)To(value, typeof(T)); } + + internal static DateTime GetMinDate(ConnectionConfig currentConnectionConfig) + { + if (currentConnectionConfig.MoreSettings == null) + { + return Convert.ToDateTime("1900-01-01"); + } + else if (currentConnectionConfig.MoreSettings.DbMinDate == null) + { + return Convert.ToDateTime("1900-01-01"); + } + else + { + return currentConnectionConfig.MoreSettings.DbMinDate.Value; + } + } + internal static Type GetUnderType(Type oldType) { Type type = Nullable.GetUnderlyingType(oldType);