Ejemplo n.º 1
0
 /// <summary>
 /// Sets up this queriable with all columns from all table
 /// sources.
 /// </summary>
 public void SelectAllColumnsFromAllSources()
 {
     for (int p = 0; p < fromSet.SetCount; ++p)
     {
         IFromTableSource table = fromSet.GetTable(p);
         AddAllFromTable(table);
     }
 }
Ejemplo n.º 2
0
        private static QueryTableSetPlanner SetupPlanners(IDatabaseConnection db, TableExpressionFromSet fromSet)
        {
            // Set up plans for each table in the from clause of the command.  For
            // sub-queries, we recurse.

            var tablePlanner = new QueryTableSetPlanner();

            for (int i = 0; i < fromSet.SetCount; ++i)
            {
                IFromTableSource table = fromSet.GetTable(i);
                if (table is FromTableSubQuerySource)
                {
                    // This represents a sub-command in the FROM clause

                    var sqlTable = (FromTableSubQuerySource)table;
                    TableSelectExpression  sqlExpr    = sqlTable.TableExpression;
                    TableExpressionFromSet sqlFromSet = sqlTable.FromSet;

                    // Form a plan for evaluating the sub-command FROM
                    IQueryPlanNode sqlPlan = FormQueryPlan(db, sqlExpr, sqlFromSet, null);

                    // The top should always be a SubsetNode,
                    if (sqlPlan is SubsetNode)
                    {
                        var subsetNode = (SubsetNode)sqlPlan;
                        subsetNode.SetGivenName(sqlTable.AliasedName);
                    }
                    else
                    {
                        throw new Exception("Top plan is not a SubsetNode!");
                    }

                    tablePlanner.AddTableSource(sqlPlan, sqlTable);
                }
                else if (table is FromTableDirectSource)
                {
                    // This represents a direct referencable table in the FROM clause
                    var            dsTable = (FromTableDirectSource)table;
                    IQueryPlanNode dsPlan  = dsTable.CreateFetchQueryPlanNode();
                    tablePlanner.AddTableSource(dsPlan, dsTable);
                }
                else
                {
                    throw new Exception("Unknown table source instance: " + table.GetType());
                }
            }

            return(tablePlanner);
        }
Ejemplo n.º 3
0
        private static QueryTableSetPlanner SetupPlanners(IDatabaseConnection db, TableExpressionFromSet fromSet)
        {
            // Set up plans for each table in the from clause of the command.  For
            // sub-queries, we recurse.

            var tablePlanner = new QueryTableSetPlanner();

            for (int i = 0; i < fromSet.SetCount; ++i) {
                IFromTableSource table = fromSet.GetTable(i);
                if (table is FromTableSubQuerySource) {
                    // This represents a sub-command in the FROM clause

                    var sqlTable = (FromTableSubQuerySource)table;
                    TableSelectExpression sqlExpr = sqlTable.TableExpression;
                    TableExpressionFromSet sqlFromSet = sqlTable.FromSet;

                    // Form a plan for evaluating the sub-command FROM
                    IQueryPlanNode sqlPlan = FormQueryPlan(db, sqlExpr, sqlFromSet, null);

                    // The top should always be a SubsetNode,
                    if (sqlPlan is SubsetNode) {
                        var subsetNode = (SubsetNode)sqlPlan;
                        subsetNode.SetGivenName(sqlTable.AliasedName);
                    } else {
                        throw new Exception("Top plan is not a SubsetNode!");
                    }

                    tablePlanner.AddTableSource(sqlPlan, sqlTable);
                } else if (table is FromTableDirectSource) {
                    // This represents a direct referencable table in the FROM clause
                    var dsTable = (FromTableDirectSource)table;
                    IQueryPlanNode dsPlan = dsTable.CreateFetchQueryPlanNode();
                    tablePlanner.AddTableSource(dsPlan, dsTable);
                } else {
                    throw new Exception("Unknown table source instance: " + table.GetType());
                }
            }

            return tablePlanner;
        }