Browse Source

Time configuration

pull/19/head
sunkaixuan 3 years ago
parent
commit
9de878be82
  1. 23
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs
  2. 24
      Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs
  3. 1
      Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs
  4. 1
      Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs
  5. 1
      Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs
  6. 1
      Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs

23
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/InsertBuilder.cs

@ -80,6 +80,29 @@ namespace SqlSugar
#endregion
#region Methods
public virtual void ActionMinDate()
{
if (this.Parameters != null)
{
foreach (var item in this.Parameters)
{
if (item.DbType == System.Data.DbType.Date || item.DbType == System.Data.DbType.DateTime)
{
if (item.Value != null && item.Value != DBNull.Value)
{
if (item.Value is DateTime)
{
if (Convert.ToDateTime(item.Value) == DateTime.MinValue)
{
item.Value = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
}
}
}
}
}
}
public virtual void Clear()
{

24
Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/UpdateBuilder.cs

@ -161,6 +161,7 @@ namespace SqlSugar
var isSingle = groupList.Count() == 1;
if (isSingle&&this.IsListUpdate==null)
{
ActionMinDate();
return ToSingleSqlString(groupList);
}
else
@ -279,7 +280,28 @@ namespace SqlSugar
}
return string.Format(SqlTemplate, GetTableNameString, columnsString, whereString);
}
public virtual void ActionMinDate()
{
if (this.Parameters != null)
{
foreach (var item in this.Parameters)
{
if (item.DbType == System.Data.DbType.Date || item.DbType == System.Data.DbType.DateTime)
{
if (item.Value != null && item.Value != DBNull.Value)
{
if (item.Value is DateTime)
{
if (Convert.ToDateTime(item.Value) == DateTime.MinValue)
{
item.Value = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig);
}
}
}
}
}
}
}
public virtual object FormatValue(object value)
{
if (value == null)

1
Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlInsertBuilder.cs

@ -106,6 +106,7 @@ namespace SqlSugar
if (isSingle)
{
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
ActionMinDate();
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
}
else

1
Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleInsertBuilder.cs

@ -44,6 +44,7 @@ namespace SqlSugar
columnsString = columnsString.TrimEnd(',') + "," + string.Join(",", identities.Select(it => Builder.GetTranslationColumnName(it.DbColumnName)));
columnParametersString = columnParametersString.TrimEnd(',') + "," + string.Join(",", identities.Select(it => it.OracleSequenceName + ".nextval"));
}
ActionMinDate();
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
}
else

1
Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLInsertBuilder.cs

@ -44,6 +44,7 @@ namespace SqlSugar
if (isSingle)
{
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
ActionMinDate();
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
}
else

1
Src/Asp.Net/SqlSugar/Realization/Sqlite/SqlBuilder/SqliteInsertBuilder.cs

@ -47,6 +47,7 @@ namespace SqlSugar
if (isSingle)
{
string columnParametersString = string.Join(",", this.DbColumnInfoList.Select(it => Builder.SqlParameterKeyWord + it.DbColumnName));
ActionMinDate();
return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
}
else

Loading…
Cancel
Save