Пример #1
0
        private BoundRelation BindDerivedTableReference(DerivedTableReferenceSyntax node)
        {
            // TODO: Ensure query has no ORDER BY unless TOP is also specified

            var query = BindQuery(node.Query);

            var namedQueryColumns   = query.OutputColumns.Where(c => !string.IsNullOrEmpty(c.Name));
            var columns             = new List <ColumnSymbol>();
            var valueSlotFromColumn = new Dictionary <ColumnSymbol, ValueSlot>();

            foreach (var queryColumn in namedQueryColumns)
            {
                var columnSymbol = new ColumnSymbol(queryColumn.Name, queryColumn.Type);
                columns.Add(columnSymbol);
                valueSlotFromColumn.Add(columnSymbol, queryColumn.ValueSlot);
            }

            var derivedTable         = new DerivedTableSymbol(columns);
            var valueSlotFactory     = new Func <TableInstanceSymbol, ColumnSymbol, ValueSlot>((ti, c) => valueSlotFromColumn[c]);
            var derivedTableInstance = new TableInstanceSymbol(node.Name.ValueText, derivedTable, valueSlotFactory);
            var boundTableReference  = new BoundDerivedTableRelation(derivedTableInstance, query.Relation);

            QueryState.IntroducedTables.Add(derivedTableInstance, node.Name);

            return(boundTableReference);
        }
 protected virtual void VisitDerivedTableRelation(BoundDerivedTableRelation node)
 {
     VisitRelation(node.Relation);
 }
Пример #3
0
 protected virtual BoundRelation RewriteDerivedTableRelation(BoundDerivedTableRelation node)
 {
     return(node.Update(node.TableInstance,
                        RewriteRelation(node.Relation)));
 }
 protected override void VisitDerivedTableRelation(BoundDerivedTableRelation node)
 {
     // Don't visit children.
 }
        private static void GetDeclaredTableInstances(List <TableInstanceSymbol> receiver, BoundDerivedTableRelation node)
        {
            var symbol = node.TableInstance;

            receiver.Add(symbol);
        }