From c373cb80a8e84aee455d76ba8aa9653016396342 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sat, 4 Nov 2023 18:24:49 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E8=BE=BE=E6=A2=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dm/SqlBuilder/DmInsertBuilder.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmInsertBuilder.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmInsertBuilder.cs index 0eb65c571..832e74edd 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmInsertBuilder.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Dm/SqlBuilder/DmInsertBuilder.cs @@ -51,6 +51,31 @@ namespace SqlSugar } return result; } + + public override object FormatValue(object value) + { + if (value != null && value is DateTime) + { + var date = value.ObjToDate(); + if (date < UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig)) + { + date = UtilMethods.GetMinDate(this.Context.CurrentConnectionConfig); + } + if (this.Context.CurrentConnectionConfig?.MoreSettings?.DisableMillisecond == true) + { + return "to_date('" + date.ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY-MM-DD HH24:MI:SS') "; + } + else + { + return "to_timestamp('" + date.ToString("yyyy-MM-dd HH:mm:ss.ffffff") + "', 'YYYY-MM-DD HH24:MI:SS.FF') "; + } + } + else + { + return base.FormatValue(value); + } + } + //public override string ToSqlString() //{ // if (IsNoInsertNull)