Browse Source

Time configuration

pull/19/head
sunkaixuan 3 years ago
parent
commit
9a806b1b74
  1. 4
      Src/Asp.Net/SqlSugar/Abstract/FastestProvider/FastestProvider.cs
  2. 3
      Src/Asp.Net/SqlSugar/Entities/ConnMoreSettings.cs
  3. 17
      Src/Asp.Net/SqlSugar/Utilities/UtilMethods.cs

4
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);

3
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");
}
}

17
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);

Loading…
Cancel
Save