From 006b336a7be4c9c8f1ded9ad364390925b1966d6 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 14 May 2024 11:38:37 +0800 Subject: [PATCH] Optimization constraint --- .../SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs | 5 ++++- .../SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index 4e8191195..af3e1f80b 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -251,7 +251,10 @@ namespace SqlSugar } public IDeleteable WhereIF(bool isWhere, Expression> expression) { - Check.ExceptionEasy(!StaticConfig.EnableAllWhereIF, "Need to program startup configuration StaticConfig. EnableAllWhereIF = true; Tip: This operation is very risky if there are no conditions it is easy to update the entire table", " 需要程序启动时配置StaticConfig.EnableAllWhereIF=true; 提示:该操作存在很大的风险如果没有条件很容易将整个表全部更新"); + if (DeleteBuilder.WhereInfos.Any() != true) + { + Check.ExceptionEasy(!StaticConfig.EnableAllWhereIF, "Need to program startup configuration StaticConfig. EnableAllWhereIF = true; Tip: This operation is very risky if there are no conditions it is easy to update the entire table", " 需要程序启动时配置StaticConfig.EnableAllWhereIF=true; 提示:该操作存在很大的风险如果没有条件很容易将整个表全部更新"); + } if (isWhere) { return Where(expression); diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs index f9532f757..550d74b50 100644 --- a/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Abstract/UpdateProvider/UpdateableProvider.cs @@ -898,7 +898,10 @@ namespace SqlSugar } public IUpdateable WhereIF(bool isWhere, Expression> expression) { - Check.ExceptionEasy(!StaticConfig.EnableAllWhereIF, "Need to program startup configuration StaticConfig. EnableAllWhereIF = true; Tip: This operation is very risky if there are no conditions it is easy to update the entire table", " 需要程序启动时配置StaticConfig.EnableAllWhereIF=true; 提示:该操作存在很大的风险如果没有条件很容易将整个表全部更新"); + if (UpdateBuilder.WhereValues.Any() != true) + { + Check.ExceptionEasy(!StaticConfig.EnableAllWhereIF, "Need to program startup configuration StaticConfig. EnableAllWhereIF = true; Tip: This operation is very risky if there are no conditions it is easy to update the entire table", " 需要程序启动时配置StaticConfig.EnableAllWhereIF=true; 提示:该操作存在很大的风险如果没有条件很容易将整个表全部更新"); + } if (isWhere) { return Where(expression);