コード例 #1
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));
        }
コード例 #2
0
        public override Expression Visit(
            [NotNull] Expression expression)
        {
            var currentExpression     = expression;
            var inExpressionOptimized =
                new EqualityPredicateInExpressionOptimizer().Visit(currentExpression);

            currentExpression = inExpressionOptimized;

            var negationOptimized1 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized1;

            var equalityExpanded =
                new EqualityPredicateExpandingVisitor().Visit(currentExpression);

            currentExpression = equalityExpanded;

            var negationOptimized2 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized2;

            var parameterDectector = new ParameterExpressionDetectingVisitor();

            parameterDectector.Visit(currentExpression);

            if (!parameterDectector.ContainsParameters &&
                !_useRelationalNullSemantics)
            {
                var optimizedNullExpansionVisitor  = new NullSemanticsOptimizedExpandingVisitor();
                var nullSemanticsExpandedOptimized = optimizedNullExpansionVisitor.Visit(currentExpression);
                if (optimizedNullExpansionVisitor.OptimizedExpansionPossible)
                {
                    currentExpression = nullSemanticsExpandedOptimized;
                }
                else
                {
                    currentExpression = new NullSemanticsExpandingVisitor()
                                        .Visit(currentExpression);
                }
            }

            if (_useRelationalNullSemantics)
            {
                currentExpression = new NotNullableExpression(currentExpression);
            }

            var negationOptimized3 =
                new PredicateNegationExpressionOptimizer()
                .Visit(currentExpression);

            currentExpression = negationOptimized3;

            return(currentExpression);
        }
        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);
        }
コード例 #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);
        }