コード例 #1
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 &&
                !_useRelationalNulls)
            {
                var optimizedNullExpansionVisitor    = new RelationalNullsOptimizedExpandingVisitor();
                var relationalNullsExpandedOptimized = optimizedNullExpansionVisitor.Visit(currentExpression);
                if (optimizedNullExpansionVisitor.OptimizedExpansionPossible)
                {
                    currentExpression = relationalNullsExpandedOptimized;
                }
                else
                {
                    currentExpression = new RelationalNullsExpandingVisitor()
                                        .Visit(currentExpression);
                }
            }

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

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

            currentExpression = negationOptimized3;

            return(currentExpression);
        }
コード例 #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
                && !_useRelationalNulls)
            {
                var optimizedNullExpansionVisitor = new RelationalNullsOptimizedExpandingVisitor();
                var relationalNullsExpandedOptimized = optimizedNullExpansionVisitor.Visit(currentExpression);
                if (optimizedNullExpansionVisitor.OptimizedExpansionPossible)
                {
                    currentExpression = relationalNullsExpandedOptimized;
                }
                else
                {
                    currentExpression = new RelationalNullsExpandingVisitor()
                        .Visit(currentExpression);
                }
            }

            if (_useRelationalNulls)
            {
                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);
        }