Collate() public static méthode

public static Collate ( Expression expression ) : Expression
expression System.Linq.Expressions.Expression
Résultat System.Linq.Expressions.Expression
Exemple #1
0
        public static Expression Optimize(DataAccessModel dataAccessModel, SqlDatabaseContext sqlDatabaseContext, Expression expression)
        {
            expression = SqlGroupByCollator.Collate(expression);
            expression = SqlAggregateSubqueryRewriter.Rewrite(expression);
            expression = SqlUnusedColumnRemover.Remove(expression);
            expression = SqlRedundantColumnRemover.Remove(expression);
            expression = SqlRedundantSubqueryRemover.Remove(expression);
            expression = SqlFunctionCoalescer.Coalesce(expression);
            expression = SqlExistsSubqueryOptimizer.Optimize(expression);
            expression = SqlRedundantBinaryExpressionsRemover.Remove(expression);
            expression = SqlCrossJoinRewriter.Rewrite(expression);
            expression = SqlConditionalEliminator.Eliminate(expression);
            expression = SqlExpressionCollectionOperationsExpander.Expand(expression);
            expression = SqlSubCollectionOrderByAmender.Amend(dataAccessModel.TypeDescriptorProvider, expression);
            expression = SqlOrderByRewriter.Rewrite(expression);

            var rewritten = SqlCrossApplyRewriter.Rewrite(expression);

            if (rewritten != expression)
            {
                expression = rewritten;
                expression = SqlUnusedColumnRemover.Remove(expression);
                expression = SqlRedundantColumnRemover.Remove(expression);
                expression = SqlRedundantSubqueryRemover.Remove(expression);
                expression = SqlOrderByRewriter.Rewrite(expression);
            }

            expression = SqlDeleteNormalizer.Normalize(expression);
            expression = SqlUpdateNormalizer.Normalize(expression);
            expression = SqlInsertIntoNormalizer.Normalize(expression);

            return(expression);
        }
Exemple #2
0
        public static Expression Optimize(Expression expression, Type typeForEnums, bool simplerPartialVal = true)
        {
            expression = SqlObjectOperandComparisonExpander.Expand(expression);
            expression = SqlEnumTypeNormalizer.Normalize(expression, typeForEnums);
            expression = SqlGroupByCollator.Collate(expression);
            expression = SqlAggregateSubqueryRewriter.Rewrite(expression);
            expression = SqlUnusedColumnRemover.Remove(expression);
            expression = SqlRedundantColumnRemover.Remove(expression);
            expression = SqlRedundantSubqueryRemover.Remove(expression);
            expression = SqlFunctionCoalescer.Coalesce(expression);
            expression = SqlExistsSubqueryOptimizer.Optimize(expression);
            expression = SqlRedundantBinaryExpressionsRemover.Remove(expression);
            expression = SqlCrossJoinRewriter.Rewrite(expression);

            if (simplerPartialVal)
            {
                expression = Evaluator.PartialEval(expression, c => c.NodeType != (ExpressionType)SqlExpressionType.ConstantPlaceholder && Evaluator.CanBeEvaluatedLocally(c));
            }
            else
            {
                expression = Evaluator.PartialEval(expression);
            }

            expression = SqlRedundantFunctionCallRemover.Remove(expression);
            expression = SqlConditionalEliminator.Eliminate(expression);
            expression = SqlExpressionCollectionOperationsExpander.Expand(expression);
            expression = SqlSumAggregatesDefaultValueCoalescer.Coalesce(expression);
            expression = SqlOrderByRewriter.Rewrite(expression);

            var rewritten = SqlCrossApplyRewriter.Rewrite(expression);

            if (rewritten != expression)
            {
                expression = rewritten;

                expression = SqlUnusedColumnRemover.Remove(expression);
                expression = SqlRedundantColumnRemover.Remove(expression);
                expression = SqlRedundantSubqueryRemover.Remove(expression);
                expression = SqlOrderByRewriter.Rewrite(expression);
            }

            return(expression);
        }