예제 #1
1
 private SqlFormatter(QueryLanguage language, bool forDebug)
 {
     this.language = language;
     this.sb = new StringBuilder();
     this.aliases = new Dictionary<TableAlias, string>();
     this.forDebug = forDebug;
 }
예제 #2
0
 private SqlFormatter(QueryLanguage language, bool forDebug)
 {
     this.language = language;
     this.sb       = new StringBuilder();
     this.aliases  = new Dictionary <TableAlias, string>();
     this.forDebug = forDebug;
 }
예제 #3
0
 protected SqlFormatter(QueryLanguage language, bool forDebug = false)
 {
     this.Language = language;
     this.sb       = new StringBuilder();
     this.aliases  = new Dictionary <TableAlias, string>();
     this.ForDebug = forDebug;
 }
예제 #4
0
 private Nominator(QueryLanguage language, ProjectionAffinity affinity)
 {
     this.language   = language;
     this.affinity   = affinity;
     this.candidates = new HashSet <Expression>();
     this.isBlocked  = false;
 }
예제 #5
0
            internal static HashSet <Expression> Nominate(QueryLanguage language, ProjectionAffinity affinity, Expression expression)
            {
                Nominator nominator = new Nominator(language, affinity);

                nominator.Visit(expression);
                return(nominator.candidates);
            }
예제 #6
0
        public static ProjectedColumns ProjectColumns(QueryLanguage language, ProjectionAffinity affinity, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases)
        {
            ColumnProjector projector = new ColumnProjector(language, affinity, expression, existingColumns, newAlias, existingAliases);
            Expression      expr      = projector.Visit(expression);

            return(new ProjectedColumns(expr, projector.columns.AsReadOnly()));
        }
        public static string WriteToString(QueryLanguage language, Expression expression)
        {
            StringWriter sw = new StringWriter();

            Write(sw, language, expression);
            return(sw.ToString());
        }
예제 #8
0
            internal static HashSet <Expression> Nominate(QueryLanguage language, Expression expression)
            {
                Nominator nominator = new Nominator(language);

                nominator.Visit(expression);
                return(nominator.candidates);
            }
예제 #9
0
 private QueryBinder(QueryMapper mapper, Expression root)
 {
     this.mapper = mapper;
     this.language = mapper.Translator.Linguist.Language;
     this.map = new Dictionary<ParameterExpression, Expression>();
     this.groupByMap = new Dictionary<Expression, GroupByInfo>();
     this.root = root;
 }
        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, TableAlias newAlias)
        {
            var newColumns =
                from d in sel.Columns
                let qt = (d.Expression is ColumnExpression) ? ((ColumnExpression)d.Expression).QueryType : language.TypeSystem.GetColumnType(d.Expression.Type)
                select new ColumnDeclaration(d.Name, new ColumnExpression(d.Expression.Type, qt, newAlias, d.Name), qt);

            var newFrom = new SelectExpression(newAlias, sel.Columns, sel.From, sel.Where, sel.OrderBy, sel.GroupBy, sel.IsDistinct, sel.Skip, sel.Take, sel.IsReverse);
            return new SelectExpression(sel.Alias, newColumns, newFrom, null, null, null, false, null, null, false);
        }
        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, TableAlias newAlias)
        {
            var newColumns =
                from d in sel.Columns
                let qt = (d.Expression is ColumnExpression) ? ((ColumnExpression)d.Expression).QueryType : language.TypeSystem.GetColumnType(d.Expression.Type)
                         select new ColumnDeclaration(d.Name, new ColumnExpression(d.Expression.Type, qt, newAlias, d.Name), qt);

            var newFrom = new SelectExpression(newAlias, sel.Columns, sel.From, sel.Where, sel.OrderBy, sel.GroupBy, sel.IsDistinct, sel.Skip, sel.Take, sel.IsReverse);

            return(new SelectExpression(sel.Alias, newColumns, newFrom, null, null, null, false, null, null, false));
        }
예제 #12
0
            public static HashSet <Expression> Nominate(QueryLanguage language, Expression expression)
            {
                var nominator = new Nominator(language);

                if (nominator != null)
                {
                    nominator.Visit(expression);
                }

                return(nominator.candidates);
            }
 public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
 {
     string colName = proj.Select.Columns.GetAvailableColumnName("Test");
     var colType = language.TypeSystem.GetColumnType(expression.Type);
     SelectExpression newSource = proj.Select.AddColumn(new ColumnDeclaration(colName, expression, colType));
     Expression newProjector =
         new OuterJoinedExpression(
             new ColumnExpression(expression.Type, colType, newSource.Alias, colName),
             proj.Projector
             );
     return new ProjectionExpression(newSource, newProjector, proj.Aggregator);
 }
예제 #14
0
 private ColumnProjector(QueryLanguage language, Expression expression, IEnumerable<ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable<TableAlias> existingAliases)
 {
     this.language = language;
     this.newAlias = newAlias;
     this.existingAliases = new HashSet<TableAlias>(existingAliases);
     this.map = new Dictionary<ColumnExpression, ColumnExpression>();
     if (existingColumns != null)
     {
         this.columns = new List<ColumnDeclaration>(existingColumns);
         this.columnNames = new HashSet<string>(existingColumns.Select(c => c.Name));
     }
     else
     {
         this.columns = new List<ColumnDeclaration>();
         this.columnNames = new HashSet<string>();
     }
     this.candidates = Nominator.Nominate(language, expression);
 }
예제 #15
0
 private ColumnProjector(QueryLanguage language, ProjectionAffinity affinity, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases)
 {
     this.language        = language;
     this.newAlias        = newAlias;
     this.existingAliases = new HashSet <TableAlias>(existingAliases);
     this.map             = new Dictionary <ColumnExpression, ColumnExpression>();
     if (existingColumns != null)
     {
         this.columns     = new List <ColumnDeclaration>(existingColumns);
         this.columnNames = new HashSet <string>(existingColumns.Select(c => c.Name));
     }
     else
     {
         this.columns     = new List <ColumnDeclaration>();
         this.columnNames = new HashSet <string>();
     }
     this.candidates = Nominator.Nominate(language, affinity, expression);
 }
 public static void Write(TextWriter writer, QueryLanguage language, Expression expression)
 {
     new DbExpressionWriter(writer, language).Visit(expression);
 }
예제 #17
0
 public static ProjectedColumns ProjectColumns(QueryLanguage language, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable <TableAlias> existingAliases)
 {
     return(ProjectColumns(language, ProjectionAffinity.Client, expression, existingColumns, newAlias, existingAliases));
 }
예제 #18
0
 protected PLSqlFormatter(QueryLanguage language)
     : base(language)
 {
 }
예제 #19
0
 private AggregateRewriter(QueryLanguage language, Expression expr)
 {
     this.language = language;
     this.map      = new Dictionary <AggregateSubqueryExpression, Expression>();
     this.lookup   = AggregateGatherer.Gather(expr).ToLookup(a => a.GroupByAlias);
 }
예제 #20
0
 public QueryTranslator(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     this.linguist = language.CreateLinguist(this);
     this.mapper = mapping.CreateMapper(this);
     this.police = policy.CreatePolice(this);
 }
 protected DbExpressionWriter(TextWriter writer, QueryLanguage language)
     : base(writer)
 {
     this.language = language;
 }
예제 #22
0
 public QueryLinguist(QueryLanguage language, QueryTranslator translator)
 {
     this._language = language;
     this._translator = translator;
 }
 private RelationshipBinder(QueryMapper mapper)
 {
     this.mapper   = mapper;
     this.mapping  = mapper.Mapping;
     this.language = mapper.Translator.Linguist.Language;
 }
예제 #24
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new SkipToNestedOrderByRewriter(language).Visit(expression);
 }
예제 #25
0
 private SkipToNestedOrderByRewriter(QueryLanguage language)
 {
     this.language = language;
 }
예제 #26
0
 private OrderByRewriter(QueryLanguage language)
 {
     this.language = language;
     this.isOuterMostSelect = true;
 }
예제 #27
0
 public OleDbQueryProvider(OleDbConnection connection, QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
     : base(connection, language, mapping, policy)
 {
 }
 public static void Write(TextWriter writer, QueryLanguage language, Expression expression)
 {
     new DbExpressionWriter(writer, language).Visit(expression);
 }
예제 #29
0
 private Nominator(QueryLanguage language)
 {
     this.language   = language;
     this.candidates = new HashSet <Expression>();
     this.isBlocked  = false;
 }
 public static Expression Rewrite(QueryPolicy policy, QueryLanguage language, Expression expression)
 {
     return(new DbClientJoinedRewriter(policy, language).Visit(expression));
 }
 private SkipToRowNumberRewriter(QueryLanguage language)
 {
     this.language = language;
 }
 private AggregateRewriter(QueryLanguage language, Expression expr)
 {
     this.language = language;
     this.map = new Dictionary<AggregateSubqueryExpression, Expression>();
     this.lookup = AggregateGatherer.Gather(expr).ToLookup(a => a.GroupByAlias);
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new ScalarSubqueryRewriter(language).Visit(expression);
 }
 private SingletonProjectionRewriter(QueryLanguage language)
 {
     this.language = language;
 }
 private DbClientJoinedRewriter(QueryPolicy policy, QueryLanguage language)
 {
     this.policy   = policy;
     this.language = language;
 }
예제 #36
0
 public static ProjectedColumns ProjectColumns(QueryLanguage language, Expression expression, IEnumerable<ColumnDeclaration> existingColumns, TableAlias newAlias, IEnumerable<TableAlias> existingAliases)
 {
     ColumnProjector projector = new ColumnProjector(language, expression, existingColumns, newAlias, existingAliases);
     Expression expr = projector.Visit(expression);
     return new ProjectedColumns(expr, projector.columns.AsReadOnly());
 }
 public static string WriteToString(QueryLanguage language, Expression expression)
 {
     StringWriter sw = new StringWriter();
     Write(sw, language, expression);
     return sw.ToString();
 }
예제 #38
0
 internal static HashSet<Expression> Nominate(QueryLanguage language, Expression expression)
 {
     Nominator nominator = new Nominator(language);
     nominator.Visit(expression);
     return nominator.candidates;
 }
 public static Expression Rewrite(QueryLanguage language, Expression expr)
 {
     return new AggregateRewriter(language, expr).Visit(expr);
 }
예제 #40
0
 protected SqlFormatter(QueryLanguage language)
     : this(language, false)
 {
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new SingletonProjectionRewriter(language).Visit(expression));
 }
예제 #42
0
 public QueryLinguist(QueryLanguage language, QueryTranslator translator)
 {
     this.language   = language;
     this.translator = translator;
 }
예제 #43
0
 public static Expression Rewrite(QueryLanguage language, Expression expr)
 {
     return(new AggregateRewriter(language, expr).Visit(expr));
 }
예제 #44
0
 private CrossApplyRewriter(QueryLanguage language)
 {
     this.language = language;
 }
예제 #45
0
 public static string Format(Expression expression, QueryLanguage language)
 {
     PLSqlFormatter formatter = new PLSqlFormatter(language);
     formatter.Visit(expression);
     return formatter.ToString();
 }
예제 #46
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new CrossApplyRewriter(language).Visit(expression);
 }
예제 #47
0
 public static ProjectedColumns ProjectColumns(QueryLanguage language, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias, params TableAlias[] existingAliases)
 {
     return(ProjectColumns(language, expression, existingColumns, newAlias, (IEnumerable <TableAlias>)existingAliases));
 }
예제 #48
0
 private Nominator(QueryLanguage language)
 {
     this.language = language;
     this.candidates = new HashSet<Expression>();
     this.isBlocked = false;
 }
 protected DbExpressionWriter(TextWriter writer, QueryLanguage language)
     : base(writer)
 {
     this.language = language;
 }
 public ScalarSubqueryRewriter(QueryLanguage language)
 {
     this.language = language;
 }
예제 #51
0
 private RelationshipBinder(QueryMapper mapper)
 {
     this.mapper = mapper;
     this.mapping = mapper.Mapping;
     this.language = mapper.Translator.Linguist.Language;
 }
 private SkipToRowNumberRewriter(QueryLanguage language)
 {
     this.language = language;
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new SkipToRowNumberRewriter(language).Visit(expression);
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return new SkipToRowNumberRewriter(language).Visit(expression);
 }
예제 #55
0
 protected SqlFormatter(QueryLanguage language)
     : this(language, false)
 {
 }
예제 #56
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new DbSkipToNestedOrderByRewriter(language).Visit(expression));
 }
예제 #57
0
 private DbSkipToNestedOrderByRewriter(QueryLanguage language)
 {
     this.language = language;
 }
예제 #58
0
 public static ProjectedColumns ProjectColumns(QueryLanguage language, Expression expression, IEnumerable<ColumnDeclaration> existingColumns, TableAlias newAlias, params TableAlias[] existingAliases)
 {
     return ProjectColumns(language, expression, existingColumns, newAlias, (IEnumerable<TableAlias>)existingAliases);
 }
예제 #59
0
 public QueryTranslator(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     this.Linguist = language.CreateLinguist(this);
     this.Mapper   = mapping.CreateMapper(this);
     this.Police   = policy.CreatePolice(this);
 }
        public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
        {
            string           colName      = proj.Select.Columns.GetAvailableColumnName("Test");
            var              colType      = language.TypeSystem.GetColumnType(expression.Type);
            SelectExpression newSource    = proj.Select.AddColumn(new ColumnDeclaration(colName, expression, colType));
            Expression       newProjector =
                new OuterJoinedExpression(
                    new ColumnExpression(expression.Type, colType, newSource.Alias, colName),
                    proj.Projector
                    );

            return(new ProjectionExpression(newSource, newProjector, proj.Aggregator));
        }