Esempio n. 1
0
        public virtual Expression Translate(Expression expression)
        {
            if (expression != null)
            {
                expression = DbUnusedColumnRemover.Remove(expression);
                expression = DbRedundantColumnRemover.Remove(expression);
                expression = DbRedundantSubqueryRemover.Remove(expression);
            }

            var rewritten = DbCrossApplyRewriter.Rewrite(this.Language, expression);

            if (rewritten != null)
            {
                rewritten = DbCrossJoinRewriter.Rewrite(rewritten);
            }

            if (rewritten != expression)
            {
                expression = rewritten;
                expression = DbUnusedColumnRemover.Remove(expression);
                expression = DbRedundantSubqueryRemover.Remove(expression);
                expression = DbRedundantJoinRemover.Remove(expression);
                expression = DbRedundantColumnRemover.Remove(expression);
            }

            return(expression);
        }
Esempio n. 2
0
        public virtual Expression Translate(Expression expression)
        {
            expression = DbQueryBinder.Bind(this, expression);
            expression = DbAggregateRewriter.Rewrite(this.Translator.Linguist.Language, expression);
            expression = DbUnusedColumnRemover.Remove(expression);
            expression = DbRedundantColumnRemover.Remove(expression);
            expression = DbRedundantSubqueryRemover.Remove(expression);
            expression = DbRedundantJoinRemover.Remove(expression);

            var bound = DbRelationshipBinder.Bind(this, expression);

            if (bound != expression)
            {
                expression = bound;
                expression = DbRedundantColumnRemover.Remove(expression);
                expression = DbRedundantJoinRemover.Remove(expression);
            }

            expression = DbComparisonRewriter.Rewrite(this.Mapping, expression);

            return(expression);
        }
Esempio n. 3
0
        public virtual Expression Translate(Expression expression)
        {
            var rewritten = DbRelationshipIncluder.Include(this.Translator.Mapper, expression);

            if (rewritten != expression)
            {
                expression = rewritten;
                expression = DbUnusedColumnRemover.Remove(expression);
                expression = DbRedundantColumnRemover.Remove(expression);
                expression = DbRedundantSubqueryRemover.Remove(expression);
                expression = DbRedundantJoinRemover.Remove(expression);
            }

            rewritten = DbSingletonProjectionRewriter.Rewrite(this.Translator.Linguist.Language, expression);

            if (rewritten != expression)
            {
                expression = rewritten;
                expression = DbUnusedColumnRemover.Remove(expression);
                expression = DbRedundantColumnRemover.Remove(expression);
                expression = DbRedundantSubqueryRemover.Remove(expression);
                expression = DbRedundantJoinRemover.Remove(expression);
            }

            rewritten = DbClientJoinedRewriter.Rewrite(this.Policy, this.Translator.Linguist.Language, expression);

            if (rewritten != expression)
            {
                expression = rewritten;
                expression = DbUnusedColumnRemover.Remove(expression);
                expression = DbRedundantColumnRemover.Remove(expression);
                expression = DbRedundantSubqueryRemover.Remove(expression);
                expression = DbRedundantJoinRemover.Remove(expression);
            }

            return(expression);
        }