From 1ba4ff006682cce9e02f832ec41c64028d41aa0d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 13 May 2022 22:06:08 +0800 Subject: [PATCH] Time configuration --- .../SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs | 4 ++-- .../SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs | 4 ++-- .../SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs | 4 ++-- .../Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs | 4 ++-- .../Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs | 4 ++-- .../Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs | 4 ++-- .../Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs | 4 ++-- .../SqlSugar/Realization/SqlServer/SqlServerProvider.cs | 2 +- .../Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs | 4 ++-- .../Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs index 17e4027f8..2c390db71 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs @@ -190,9 +190,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs index 99d88dc44..3ff75b7ba 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs @@ -292,9 +292,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; } diff --git a/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs index 7e90c936c..78d25c6ce 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs @@ -52,9 +52,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs index 65f0db8e0..230f8a2df 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs @@ -45,9 +45,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs index 1d702316b..7a6857324 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlUpdateBuilder.cs @@ -107,9 +107,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; } diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs index 1d54b41af..20e588351 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs @@ -117,9 +117,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } if (this.Context.CurrentConnectionConfig?.MoreSettings?.DisableMillisecond == true) { diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs index ebce18d47..e5892ac12 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs @@ -53,9 +53,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } if (this.Context.CurrentConnectionConfig?.MoreSettings?.DisableMillisecond == true) { diff --git a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlServerProvider.cs b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlServerProvider.cs index c02c5c2c3..96d15fdf4 100644 --- a/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlServerProvider.cs +++ b/Src/Asp.Net/SqlSugar/Realization/SqlServer/SqlServerProvider.cs @@ -141,7 +141,7 @@ namespace SqlSugar var date = Convert.ToDateTime(sqlParameter.Value); if (date==DateTime.MinValue) { - sqlParameter.Value = Convert.ToDateTime("1753/01/01"); + sqlParameter.Value =UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } } if (parameter.Direction == 0) diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs index ed7d87e44..7f127ae6f 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs @@ -91,9 +91,9 @@ namespace SqlSugar if (type == UtilConstants.DateType) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } if (this.Context.CurrentConnectionConfig?.MoreSettings?.DisableMillisecond == true) { diff --git a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs index a1f1f4560..a82d5209c 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteUpdateBuilder.cs @@ -47,9 +47,9 @@ namespace SqlSugar if (type == UtilConstants.DateType && iswhere == false) { var date = value.ObjToDate(); - if (date < Convert.ToDateTime("1900-1-1")) + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) { - date = Convert.ToDateTime("1900-1-1"); + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); } if (this.Context.CurrentConnectionConfig?.MoreSettings?.DisableMillisecond == true) {