Browse Source

Update nav query

pull/23/head
sunkaixuan 2 years ago
parent
commit
82f2a7751d
  1. 15
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs

15
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/NavSelectHelper.cs

@ -275,6 +275,7 @@ namespace SqlSugar
private static List<NavMappingColumn> GetMappingColumn(Expression expression)
{
var body = ExpressionTool.GetLambdaExpressionBody(expression);
var parameterName=(expression as LambdaExpression).Parameters.FirstOrDefault().Name;
List<NavMappingColumn> result = new List<NavMappingColumn>();
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<NavMappingColumn> result, Expression item)
private static void AddCallError(List<NavMappingColumn> 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<T, TResult>(Expression<Func<T, TResult>> expression, QueryableProvider<T> queryableProvider)

Loading…
Cancel
Save