Time configuration

This commit is contained in:
sunkaixuan
2022-05-13 21:53:22 +08:00
parent b27e322bb2
commit 9a806b1b74
3 changed files with 23 additions and 1 deletions

View File

@@ -177,6 +177,10 @@ namespace SqlSugar
{ {
item[col.ColumnName] = string.Empty; item[col.ColumnName] = string.Empty;
} }
else if (col.DataType == UtilConstants.DateType)
{
item[col.ColumnName] =UtilMethods.GetMinDate(this.context.CurrentConnectionConfig);
}
else else
{ {
item[col.ColumnName] = Activator.CreateInstance(col.DataType); item[col.ColumnName] = Activator.CreateInstance(col.DataType);

View File

@@ -15,5 +15,6 @@ namespace SqlSugar
public bool PgSqlIsAutoToLower = true; public bool PgSqlIsAutoToLower = true;
public int DefaultCacheDurationInSeconds { get; set; } 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");
} }
} }

View File

@@ -193,6 +193,23 @@ namespace SqlSugar
{ {
return (T)To(value, typeof(T)); 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) internal static Type GetUnderType(Type oldType)
{ {
Type type = Nullable.GetUnderlyingType(oldType); Type type = Nullable.GetUnderlyingType(oldType);