/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public override Expression Visit(Expression expression) { if (expression == null) { return(null); } if (expression is NewExpression || expression is MemberInitExpression || expression is EntityShaperExpression) { return(base.Visit(expression)); } // This skips the group parameter from GroupJoin if (expression is ParameterExpression parameter && parameter.Type.IsGenericType && parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { return(parameter); } if (_clientEval) { switch (expression) { case ConstantExpression _: return(expression); case ParameterExpression parameterExpression: if (_collectionShaperMapping.ContainsKey(parameterExpression)) { return(parameterExpression); } return(Expression.Call( _getParameterValueMethodInfo.MakeGenericMethod(parameterExpression.Type), QueryCompilationContext.QueryContextParameter, Expression.Constant(parameterExpression.Name))); case MaterializeCollectionNavigationExpression _: return(base.Visit(expression)); } var translation = _sqlTranslator.Translate(expression); if (translation == null) { return(base.Visit(expression)); } return(new ProjectionBindingExpression( _selectExpression, _selectExpression.AddToProjection(translation), expression.Type)); } else { var translation = _sqlTranslator.Translate(expression); if (translation == null) { return(null); } _projectionMapping[_projectionMembers.Peek()] = translation; return(new ProjectionBindingExpression(_selectExpression, _projectionMembers.Peek(), expression.Type)); } }
private SqlExpression TranslateExpression(Expression expression) => _sqlTranslator.Translate(expression);