diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlBlukCopy.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlBlukCopy.cs index f7a4219bf..6e4ead42c 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlBlukCopy.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlBlukCopy.cs @@ -176,6 +176,10 @@ namespace SqlSugar.MySqlConnector { sb.Append(row[colum].ObjToDate().ToString("yyyy-MM-dd HH:mm:ss.fff")); } + else if (colum.DataType == UtilConstants.DateType && row[colum] != null && row[colum] == DBNull.Value) + { + sb.Append("NULL"); + } else sb.Append(row[colum].ToString()); } sb.AppendLine(); diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs index c7bce8d2e..5fe8d0b44 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlInsertBuilder.cs @@ -44,12 +44,11 @@ namespace SqlSugar.MySqlConnector var type = UtilMethods.GetUnderType(value.GetType()); if (type == UtilConstants.DateType) { - var date = value.ObjToDate(); - if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) - { - date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); - } - return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + return GetDateTimeString(value); + } + else if (value is DateTimeOffset) + { + return GetDateTimeOffsetString(value); } else if (type == UtilConstants.ByteArrayType) { @@ -84,6 +83,27 @@ namespace SqlSugar.MySqlConnector } } } + + private object GetDateTimeOffsetString(object value) + { + var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value); + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) + { + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); + } + return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + } + + private object GetDateTimeString(object value) + { + var date = value.ObjToDate(); + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) + { + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); + } + return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + } + private string GetString(object value) { var result = value.ToString(); diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs index 737811f52..1278400d7 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlQueryBuilder.cs @@ -66,6 +66,10 @@ namespace SqlSugar.MySqlConnector { return "-- No table"; } + if (TranLock != null) + { + result = result + TranLock; + } return result; } private string ToCountSqlString() diff --git a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs index f4cb51c15..5d95fe171 100644 --- a/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar.MySqlConnectorCore/MySql/SqlBuilder/MySqlUpdateBuilder.cs @@ -106,12 +106,11 @@ namespace SqlSugar.MySqlConnector var type = UtilMethods.GetUnderType(value.GetType()); if (type == UtilConstants.DateType) { - var date = value.ObjToDate(); - if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) - { - date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); - } - return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + return GetDateTimeString(value); + } + else if (value is DateTimeOffset) + { + return GetDateTimeOffsetString(value); } else if (type == UtilConstants.ByteArrayType) { @@ -154,6 +153,27 @@ namespace SqlSugar.MySqlConnector } } } + + private object GetDateTimeString(object value) + { + var date = value.ObjToDate(); + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) + { + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); + } + return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + } + + private object GetDateTimeOffsetString(object value) + { + var date = UtilMethods.ConvertFromDateTimeOffset((DateTimeOffset)value); + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) + { + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); + } + return "'" + date.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + } + private string GetString(object value) { var result = value.ToString();