Esempio n. 1
0
        public static string WriteToString(QueryLanguage language, Expression expression)
        {
            var sw = new StringWriter();

            Write(sw, language, expression);
            return(sw.ToString());
        }
Esempio n. 2
0
            internal static HashSet <Expression> Nominate(QueryLanguage language, Expression expression)
            {
                var nominator = new Nominator(language);

                nominator.Visit(expression);
                return(nominator.candidates);
            }
Esempio n. 3
0
 private SqlFormatter(QueryLanguage language, bool forDebug)
 {
     this.language = language;
     sb            = new StringBuilder();
     aliases       = new Dictionary <TableAlias, string>();
     this.forDebug = forDebug;
 }
Esempio n. 4
0
        public static ProjectedColumns ProjectColumns(QueryLanguage language, Expression expression, IEnumerable <ColumnDeclaration> existingColumns, TableAlias newAlias,
                                                      IEnumerable <TableAlias> existingAliases)
        {
            var        projector = new ColumnProjector(language, expression, existingColumns, newAlias, existingAliases);
            Expression expr      = projector.Visit(expression);

            return(new ProjectedColumns(expr, projector.columns.AsReadOnly()));
        }
Esempio n. 5
0
        public static SelectExpression AddRedundantSelect(this SelectExpression sel, QueryLanguage language, TableAlias newAlias)
        {
            IEnumerable <ColumnDeclaration> 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));
        }
Esempio n. 6
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);
     map = new Dictionary <ColumnExpression, ColumnExpression>();
     if (existingColumns != null)
     {
         columns     = new List <ColumnDeclaration>(existingColumns);
         columnNames = new HashSet <string>(existingColumns.Select(c => c.Name));
     }
     else
     {
         columns     = new List <ColumnDeclaration>();
         columnNames = new HashSet <string>();
     }
     candidates = Nominator.Nominate(language, expression);
 }
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new SingletonProjectionRewriter(language).Visit(expression));
 }
 private SingletonProjectionRewriter(QueryLanguage language)
 {
     this.language = language;
 }
Esempio n. 9
0
 public static Expression Parameterize(QueryLanguage language, Expression expression)
 {
     return(new Parameterizer(language).Visit(expression));
 }
Esempio n. 10
0
 private Parameterizer(QueryLanguage language)
 {
     this.language = language;
 }
Esempio n. 11
0
 public static Expression Rewrite(QueryLanguage language, Expression expr)
 {
     return(new AggregateRewriter(language, expr).Visit(expr));
 }
Esempio n. 12
0
 private OrderByRewriter(QueryLanguage language)
 {
     this.language     = language;
     isOuterMostSelect = true;
 }
Esempio n. 13
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new SkipToRowNumberRewriter(language).Visit(expression));
 }
Esempio n. 14
0
 private ClientJoinedProjectionRewriter(QueryPolicy policy, QueryLanguage language)
 {
     this.policy   = policy;
     this.language = language;
 }
Esempio n. 15
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new SkipToNestedOrderByRewriter(language).Visit(expression));
 }
Esempio n. 16
0
 private SkipToNestedOrderByRewriter(QueryLanguage language)
 {
     this.language = language;
 }
Esempio n. 17
0
 public QueryLinguist(QueryLanguage language, QueryTranslator translator)
 {
     this.language   = language;
     this.translator = translator;
 }
Esempio n. 18
0
 public static Expression Rewrite(QueryPolicy policy, QueryLanguage language, Expression expression)
 {
     return(new ClientJoinedProjectionRewriter(policy, language).Visit(expression));
 }
Esempio n. 19
0
 public static void Write(TextWriter writer, QueryLanguage language, Expression expression)
 {
     new DbExpressionWriter(writer, language).Visit(expression);
 }
Esempio n. 20
0
 protected DbExpressionWriter(TextWriter writer, QueryLanguage language) : base(writer)
 {
     this.language = language;
 }
Esempio n. 21
0
 public QueryTranslator(QueryLanguage language, QueryMapping mapping, QueryPolicy policy)
 {
     linguist = language.CreateLinguist(this);
     mapper   = mapping.CreateMapper(this);
     police   = policy.CreatePolice(this);
 }
Esempio n. 22
0
 private SkipToRowNumberRewriter(QueryLanguage language)
 {
     this.language = language;
 }
Esempio n. 23
0
 protected SqlFormatter(QueryLanguage language) : this(language, false)
 {
 }
Esempio n. 24
0
 private Nominator(QueryLanguage language)
 {
     this.language = language;
     candidates    = new HashSet <Expression>();
     isBlocked     = false;
 }
Esempio n. 25
0
 private CrossApplyRewriter(QueryLanguage language)
 {
     this.language = language;
 }
Esempio n. 26
0
 public static Expression Rewrite(QueryLanguage language, Expression expression)
 {
     return(new CrossApplyRewriter(language).Visit(expression));
 }
Esempio n. 27
0
 private AggregateRewriter(QueryLanguage language, Expression expr)
 {
     this.language = language;
     map           = new Dictionary <AggregateSubqueryExpression, Expression>();
     lookup        = AggregateGatherer.Gather(expr).ToLookup(a => a.GroupByAlias);
 }
Esempio n. 28
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));
 }
Esempio n. 29
0
        public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
        {
            string           colName      = proj.Select.Columns.GetAvailableColumnName("Test");
            QueryType        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));
        }