From a47eaa44a428f2cdea7cb6f68fe3c2f3d47f78fc Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 30 May 2023 12:25:14 +0800 Subject: [PATCH] Update exp to sql --- .../SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs | 5 +++-- .../SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs index 7ec5acae0..394b412ac 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubAnd.cs @@ -43,7 +43,8 @@ namespace SqlSugar var argExp = exp.Arguments[0]; var copyContext = this.Context; - if (this.Context.JoinIndex > 0) + var pars = ExpressionTool.GetParameters(expression).Distinct(); + if (this.Context.JoinIndex > 0|| pars.Count()>1) { copyContext = this.Context.GetCopyContextWithMapping(); copyContext.IsSingle = false; @@ -51,7 +52,7 @@ namespace SqlSugar var result = "AND " + SubTools.GetMethodValue(copyContext, argExp, ResolveExpressType.WhereMultiple); - if (this.Context.JoinIndex > 0) + if (this.Context.JoinIndex > 0 || pars.Count() > 1) { this.Context.Parameters.AddRange(copyContext.Parameters); this.Context.Index = copyContext.Index; diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs index d72756fcf..bc274373c 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubWhere.cs @@ -46,14 +46,15 @@ namespace SqlSugar } var argExp = exp.Arguments[0]; var copyContext = this.Context; - if (this.Context.JoinIndex > 0) + var pars=ExpressionTool.GetParameters(expression).Distinct(); + if (this.Context.JoinIndex > 0|| pars.Count()>1) { copyContext = this.Context.GetCopyContextWithMapping(); copyContext.IsSingle = false; } var result = "WHERE " + SubTools.GetMethodValue(copyContext, argExp, ResolveExpressType.WhereMultiple); - if (this.Context.JoinIndex > 0) + if (this.Context.JoinIndex > 0 ||pars.Count() > 1) { this.Context.Parameters.AddRange(copyContext.Parameters); this.Context.Index = copyContext.Index;