mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Update Core
This commit is contained in:
@@ -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);
|
||||
|
@@ -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()
|
||||
{
|
||||
|
||||
@@ -190,9 +213,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") + "'";
|
||||
}
|
||||
|
@@ -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)
|
||||
@@ -292,9 +314,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") + "'";
|
||||
}
|
||||
|
@@ -15,5 +15,6 @@ namespace SqlSugar
|
||||
public bool PgSqlIsAutoToLower = true;
|
||||
public int DefaultCacheDurationInSeconds { get; set; }
|
||||
public bool? TableEnumIsString { get; set; }
|
||||
public DateTime? DbMinDate { get; set; } = Convert.ToDateTime("1900-01-01");
|
||||
}
|
||||
}
|
||||
|
@@ -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") + "'";
|
||||
}
|
||||
|
@@ -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") + "'";
|
||||
}
|
||||
@@ -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
|
||||
|
@@ -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") + "'";
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -117,9 +118,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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
@@ -91,9 +92,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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user