From 82f2a7751d050a82f08bcf556e8f7ce54b04a4f1 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 21 Oct 2022 10:57:40 +0800 Subject: [PATCH] Update nav query --- .../Abstract/QueryableProvider/NavSelectHelper.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs index 7cbfd120c..376091efd 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs @@ -275,6 +275,7 @@ namespace SqlSugar private static List GetMappingColumn(Expression expression) { var body = ExpressionTool.GetLambdaExpressionBody(expression); + var parameterName=(expression as LambdaExpression).Parameters.FirstOrDefault().Name; List result = new List(); if (body is NewExpression) { @@ -286,7 +287,7 @@ namespace SqlSugar var name=members[index].Name; if (item is MethodCallExpression) { - AddCallError(result, item); + AddCallError(result, item, parameterName); } index++; } @@ -304,14 +305,14 @@ namespace SqlSugar } else if(memberAssignment.Expression is MethodCallExpression) { - AddCallError(result, memberAssignment.Expression); + AddCallError(result, memberAssignment.Expression,parameterName); } } } return result; } - private static void AddCallError(List result, Expression item) + private static void AddCallError(List result, Expression item,string parameterName) { var method = (item as MethodCallExpression); if (method.Method.Name == "ToList" && method.Arguments.Count > 0 && method.Arguments[0] is MethodCallExpression) @@ -325,6 +326,14 @@ namespace SqlSugar result.Add(new NavMappingColumn() { IsError = true }); } } + else if (method.Method.Name == "Join") + { + + if (item.ToString().Contains($" {parameterName}.")) + { + result.Add(new NavMappingColumn() { IsError = true }); + } + } } private static bool isGroup(Expression> expression, QueryableProvider queryableProvider)