From 005caf242fff92020a0ef82a357c425f64aa2973 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 7 May 2023 13:02:53 +0800 Subject: [PATCH] =?UTF-8?q?Oracle=20=20=E8=BE=BE=E6=A2=A6=20=20=20Update?= =?UTF-8?q?=20Join?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Realization/Dm/SqlBuilder/DmUpdateBuilder.cs | 11 +++++++++++ .../Oracle/SqlBuilder/OracleUpdateBuilder.cs | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs index 1ebdf5d97..0ce19c760 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Dm/SqlBuilder/DmUpdateBuilder.cs @@ -7,6 +7,17 @@ namespace SqlSugar { public class DmUpdateBuilder : UpdateBuilder { + protected override string GetJoinUpdate(string columnsString, ref string whereString) + { + var joinString = $" {Builder.GetTranslationColumnName(this.TableName)} {Builder.GetTranslationColumnName(this.ShortName)} "; + foreach (var item in this.JoinInfos) + { + joinString += $"\r\n USING {Builder.GetTranslationColumnName(item.TableName)} {Builder.GetTranslationColumnName(item.ShortName)} ON {item.JoinWhere} "; + } + var tableName = joinString + "\r\n "; + var newTemp = SqlTemplate.Replace("UPDATE", "MERGE INTO").Replace("SET", "WHEN MATCHED THEN \r\nUPDATE SET"); + return string.Format(newTemp, tableName, columnsString, whereString); + } protected override string TomultipleSqlString(List> groupList) { StringBuilder sb = new StringBuilder(); diff --git a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs index c39494312..8ef9d6f86 100644 --- a/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs +++ b/Src/Asp.Net/SqlSugar/Realization/Oracle/SqlBuilder/OracleUpdateBuilder.cs @@ -116,7 +116,17 @@ namespace SqlSugar } } } - + protected override string GetJoinUpdate(string columnsString, ref string whereString) + { + var joinString = $" {Builder.GetTranslationColumnName(this.TableName)} {Builder.GetTranslationColumnName(this.ShortName)} "; + foreach (var item in this.JoinInfos) + { + joinString += $"\r\n USING {Builder.GetTranslationColumnName(item.TableName)} {Builder.GetTranslationColumnName(item.ShortName)} ON {item.JoinWhere} "; + } + var tableName = joinString + "\r\n "; + var newTemp = SqlTemplate.Replace("UPDATE", "MERGE INTO").Replace("SET", "WHEN MATCHED THEN \r\nUPDATE SET"); + return string.Format(newTemp, tableName, columnsString, whereString); + } #region Helper public bool IsUppper {