From 1c27b1ab1c18a37c8e544946e79c5a6e23287a46 Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Sat, 15 Jan 2022 19:03:57 +0800 Subject: [PATCH] update GetDiffTable --- Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs | 3 +++ .../SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs b/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs index 367eecf6e..dfd332c46 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs @@ -68,6 +68,9 @@ namespace OrmTest db.Updateable().SetColumns(it=>it.Name=="asdfa").Where(it=>it.Id==1).EnableDiffLogEvent("--update Order--").ExecuteCommand(); + + db.Updateable().SetColumns(it => it.Name == "asdfa") + .Where(it =>SqlFunc.Subqueryable().Where(x=>x.Id==it.Id).Any()).EnableDiffLogEvent("--update Order--").ExecuteCommand(); Console.WriteLine("#### Aop End ####"); } } diff --git a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index 401570324..5ca8ebe55 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -840,6 +840,10 @@ namespace SqlSugar if (this.UpdateParameterIsNull) { var whereSql = Regex.Replace(sql, ".* WHERE ", "", RegexOptions.Singleline); + if (sql.Contains("WHERE (EXISTS")) + { + whereSql=Regex.Match(sql, @"\(EXISTS.+").Value; + } dt = this.Context.Queryable().Where(whereSql).AddParameters(parameters).ToDataTable(); } else