Example #1
0
        /// <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>
        protected override Expression VisitExtension(Expression expression)
        {
            var selectExpression = expression as SelectExpression;

            if (selectExpression?.Predicate != null)
            {
                var predicate = new EqualityPredicateInExpressionOptimizer().Visit(selectExpression.Predicate);

                var predicateNegationExpressionOptimizer = new PredicateNegationExpressionOptimizer();

                predicate = predicateNegationExpressionOptimizer.Visit(predicate);

                predicate = new PredicateReductionExpressionOptimizer().Visit(predicate);

                predicate = new EqualityPredicateExpandingVisitor().Visit(predicate);

                predicate = predicateNegationExpressionOptimizer.Visit(predicate);

                if (_useRelationalNulls)
                {
                    predicate = new NullCompensatedExpression(predicate);
                }

                selectExpression.Predicate = predicate;
            }
            else if (expression is PredicateJoinExpressionBase joinExpression)
            {
                joinExpression.Predicate = new DiscriminatorPredicateOptimizingVisitor().Visit(joinExpression.Predicate);

                joinExpression.Predicate = new EqualityPredicateInExpressionOptimizer().Visit(joinExpression.Predicate);
            }

            return(base.VisitExtension(expression));
        }
Example #2
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        protected override Expression VisitExtension(Expression expression)
        {
            var selectExpression = expression as SelectExpression;

            if (selectExpression?.Predicate != null)
            {
                var predicate = new EqualityPredicateInExpressionOptimizer().Visit(selectExpression.Predicate);

                var predicateNegationExpressionOptimizer = new PredicateNegationExpressionOptimizer();

                predicate = predicateNegationExpressionOptimizer.Visit(predicate);

                predicate = new PredicateReductionExpressionOptimizer().Visit(predicate);

                predicate = new EqualityPredicateExpandingVisitor().Visit(predicate);

                predicate = predicateNegationExpressionOptimizer.Visit(predicate);

                if (_useRelationalNulls)
                {
                    predicate = new NotNullableExpression(predicate);
                }

                selectExpression.Predicate = predicate;
            }

            return(base.VisitExtension(expression));
        }
Example #3
0
        public override Expression Visit([NotNull] Expression node)
        {
            node = new EqualityPredicateInExpressionOptimizer().Visit(node);

            var predicateNegationExpressionOptimizer = new PredicateNegationExpressionOptimizer();

            node = predicateNegationExpressionOptimizer.Visit(node);

            node = new EqualityPredicateExpandingVisitor().Visit(node);

            node = predicateNegationExpressionOptimizer.Visit(node);

            if (_useRelationalNulls)
            {
                node = new NotNullableExpression(node);
            }

            return(node);
        }
Example #4
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public override Expression Visit(Expression expression)
        {
            if (expression != null)
            {
                expression = new EqualityPredicateInExpressionOptimizer().Visit(expression);

                var predicateNegationExpressionOptimizer = new PredicateNegationExpressionOptimizer();

                expression = predicateNegationExpressionOptimizer.Visit(expression);

                expression = new PredicateReductionExpressionOptimizer().Visit(expression);

                expression = new EqualityPredicateExpandingVisitor().Visit(expression);

                expression = predicateNegationExpressionOptimizer.Visit(expression);

                if (_useRelationalNulls)
                {
                    expression = new NotNullableExpression(expression);
                }
            }

            return(expression);
        }