From ca3135e815ea89f6aeb83b002e5e2650476cf8e5 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 7 Oct 2022 22:21:39 +0800 Subject: [PATCH] Update exp to sql --- .../Subquery/Items/SubSelectStringJoin.cs | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelectStringJoin.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelectStringJoin.cs index f55fa97f2..98cd7cb93 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelectStringJoin.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubSelectStringJoin.cs @@ -42,12 +42,13 @@ namespace SqlSugar public string GetValue(Expression expression = null) { var exp = expression as MethodCallExpression; - var entityType = (exp.Arguments[0] as LambdaExpression).Parameters[0].Type; - if (this.Context.InitMappingInfo != null) - { - this.Context.InitMappingInfo(entityType); - this.Context.RefreshMapping(); - } + //var entityType = (exp.Arguments[0] as LambdaExpression).Parameters[0].Type; + //if (this.Context.InitMappingInfo != null) + //{ + // this.Context.InitMappingInfo(entityType); + // this.Context.RefreshMapping(); + //} + InitType(exp); var result = ""; if (this.Context.JoinIndex == 0) result = SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle); @@ -60,7 +61,17 @@ namespace SqlSugar return result; } - + private void InitType(MethodCallExpression exp) + { + foreach (var arg in (exp.Arguments[0] as LambdaExpression).Parameters) + { + if (this.Context.InitMappingInfo != null) + { + this.Context.InitMappingInfo(arg.Type); + this.Context.RefreshMapping(); + } + } + } public void SetShortName(MethodCallExpression exp, string result) { if (exp.Arguments[0] is LambdaExpression && result.IsContainsIn("+", "-", "*", "/"))