Beispiel #1
0
 public void AddTablesFromCommonTableExpressions(SqlCommonTableExpressionCollection commonTableExpressions, Dictionary <string, Table> tables)
 {
     foreach (var commonTableExpression in commonTableExpressions)
     {
         var command = new MemoryDbCommand(Command.Connection, Command.Parameters, Command.Variables);
         var rawData = new RawData(command);
         var batch   = new ExecuteQueryStatement(Database, command).Execute(Database.Tables, rawData, (SqlQuerySpecification)commonTableExpression.QueryExpression);
         var name    = commonTableExpression.Name.Value;
         var table   = CreateTable(name, null, batch, commonTableExpression.ColumnList);
         table.Rows.AddRange(batch.ResultRows);
         _CommonTableList.Add(table);
     }
 }
Beispiel #2
0
        private List <RawTableJoinRow> GetAllViewRows(SqlCreateAlterViewStatementBase view, string name)
        {
            var command    = new MemoryDbCommand(Command.Connection, Command.Parameters, Command.Variables);
            var rawData    = new RawData(command);
            var batch      = new ExecuteQueryStatement(Database, command).Execute(Database.Tables, rawData, (SqlQuerySpecification)view.Definition.QueryExpression);
            var identifier = view.Definition.Name;

            if (TableAliasList.ContainsKey(name) == false)
            {
                var table = CreateTable(name, identifier, batch, null);
                TableAliasList.Add(name, table);
            }

            return(ResultBatch2RowList(TableAliasList[name], batch));
        }
Beispiel #3
0
        private void AddRowsFromSelect(Table table, List <Column> columns, SqlSelectSpecificationInsertSource selectSource)
        {
            var command = new MemoryDbCommand(_Command);
            var rawData = new RawData(command);
            var select  = selectSource.SelectSpecification;
            var batch   = new ExecuteQueryStatement(_Database, command, columns).Execute(rawData, _Database.Tables, select.QueryExpression, select.OrderByClause);

            foreach (var resultRow in batch.ResultRows)
            {
                var row = InitializeNewRow(table, columns);
                for (int index = 0; index < columns.Count; index++)
                {
                    row[columns[index].Order] = resultRow[index];
                }

                AddRowToTable(table, row);
            }
        }