From 68cf9caa520e293d7322fd321533175ebea814fc Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Mon, 10 Oct 2022 14:10:32 +0800 Subject: [PATCH] Update DistinctCount --- .../Subquery/Items/SubDistinctCount.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubDistinctCount.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubDistinctCount.cs index 9dce7b297..affccb879 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubDistinctCount.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/Subquery/Items/SubDistinctCount.cs @@ -44,6 +44,7 @@ namespace SqlSugar { var exp = expression as MethodCallExpression; var argExp = exp.Arguments[0]; + InitType(exp); var parametres = (argExp as LambdaExpression).Parameters; if ((argExp as LambdaExpression).Body is UnaryExpression) { @@ -64,5 +65,17 @@ namespace SqlSugar result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); 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(); + } + } + } + } }