Remove() static private method

static private Remove ( Expression expression ) : Expression
expression System.Linq.Expressions.Expression
return System.Linq.Expressions.Expression
Example #1
0
        internal static Expression Optimize(Expression binded, QueryBinder binder, AliasGenerator aliasGenerator, HeavyProfiler.Tracer log)
        {
            log.Switch("Aggregate");
            Expression rewrited = AggregateRewriter.Rewrite(binded);

            log.Switch("EntityCompleter");
            Expression completed = EntityCompleter.Complete(rewrited, binder);

            log.Switch("AliasReplacer");
            Expression replaced = AliasProjectionReplacer.Replace(completed, aliasGenerator);

            log.Switch("OrderBy");
            Expression orderRewrited = OrderByRewriter.Rewrite(replaced);

            log.Switch("Rebinder");
            Expression rebinded = QueryRebinder.Rebind(orderRewrited);

            log.Switch("UnusedColumn");
            Expression columnCleaned = UnusedColumnRemover.Remove(rebinded);

            log.Switch("Redundant");
            Expression subqueryCleaned = RedundantSubqueryRemover.Remove(columnCleaned);

            log.Switch("Condition");
            Expression rewriteConditions = ConditionsRewriter.Rewrite(subqueryCleaned);

            log.Switch("Scalar");
            Expression scalar = ScalarSubqueryRewriter.Rewrite(rewriteConditions);

            return(scalar);
        }
Example #2
0
        protected internal override Expression VisitChildProjection(ChildProjectionExpression child)
        {
            Expression           key  = this.Visit(child.OuterKey);
            ProjectionExpression proj = (ProjectionExpression)UnusedColumnRemover.Remove(child.Projection);

            if (proj != child.Projection || key != child.OuterKey)
            {
                return(new ChildProjectionExpression(proj, key, child.IsLazyMList, child.Type, child.Token));
            }
            return(child);
        }
Example #3
0
        static internal ProjectionExpression Flatten(ProjectionExpression proj, AliasGenerator aliasGenerator)
        {
            var result = (ProjectionExpression) new ChildProjectionFlattener(aliasGenerator).Visit(proj);

            if (result == proj)
            {
                return(result);
            }

            Expression columnCleaned   = UnusedColumnRemover.Remove(result);
            Expression subqueryCleaned = RedundantSubqueryRemover.Remove(columnCleaned);

            return((ProjectionExpression)subqueryCleaned);
        }
Example #4
0
        internal static Expression Optimize(Expression binded, QueryBinder binder, AliasGenerator aliasGenerator, HeavyProfiler.Tracer?log)
        {
            var isPostgres = Schema.Current.Settings.IsPostgres;


            log.Switch("Aggregate");
            Expression rewriten = AggregateRewriter.Rewrite(binded);

            log.Switch("DupHistory");
            Expression dupHistory = DuplicateHistory.Rewrite(rewriten, aliasGenerator);

            log.Switch("EntityCompleter");
            Expression completed = EntityCompleter.Complete(dupHistory, binder);

            log.Switch("AliasReplacer");
            Expression replaced = AliasProjectionReplacer.Replace(completed, aliasGenerator);

            log.Switch("OrderBy");
            Expression orderRewrited = OrderByRewriter.Rewrite(replaced);

            log.Switch("Rebinder");
            Expression rebinded = QueryRebinder.Rebind(orderRewrited);

            log.Switch("UnusedColumn");
            Expression columnCleaned = UnusedColumnRemover.Remove(rebinded);

            log.Switch("Redundant");
            Expression subqueryCleaned = RedundantSubqueryRemover.Remove(columnCleaned);

            log.Switch("Condition");
            Expression rewriteConditions = isPostgres ? ConditionsRewriterPostgres.Rewrite(subqueryCleaned) : ConditionsRewriter.Rewrite(subqueryCleaned);

            log.Switch("Scalar");
            Expression scalar = ScalarSubqueryRewriter.Rewrite(rewriteConditions);

            return(scalar);
        }