예제 #1
0
        private Table CreateTable(string name, SqlObjectIdentifier identifier, MemoryDbDataReader.ResultBatch batch,
                                  SqlIdentifierCollection columnList)
        {
            if (columnList != null)
            {
                if (columnList.Count > batch.Fields.Count)
                {
                    throw new SqlInsertTooManyColumnsException( );
                }

                if (columnList.Count < batch.Fields.Count)
                {
                    throw new SqlInsertTooManyValuesException( );
                }
            }
            var table = (identifier != null) ? new Table(identifier) : new Table(name);

            for (int fieldIndex = 0; fieldIndex < batch.Fields.Count; fieldIndex++)
            {
                var field   = batch.Fields[fieldIndex];
                var sqlType = Helper.DbType2SqlType(field.DbType);

                var columnName = columnList != null ? columnList[fieldIndex].Value : field.Name;
                var select     = (field as MemoryDbDataReader.ReaderFieldData)?.SelectFieldData;
                var tc         = (select as SelectDataFromColumn)?.TableColumn;
                var column     = tc != null
                    ? new Column(tc.Column, columnName, table.Columns.Count)
                    : new Column(table, columnName, sqlType, Database.UserDataTypes, table.Columns.Count);
                table.Columns.Add(column);
            }

            return(table);
        }
예제 #2
0
        protected int ProcessColumnList(int nextToken, SqlIdentifierCollection columnList, NormalizeWhitespace normalizer)
        {
            // find where the columns start
            IEnumerator <SqlIdentifier> columnEnum = columnList.GetEnumerator();

            if (columnEnum.MoveNext())
            {
                ProcessAndNormalizeWhitespaceRange(nextToken, columnEnum.Current.Position.startTokenNumber, normalizer);

                ProcessChild(columnEnum.Current);
                SqlIdentifier previousColumn = columnEnum.Current;
                while (columnEnum.MoveNext())
                {
                    CommaSeparatedList.ProcessInterChildRegion(previousColumn, columnEnum.Current);
                    ProcessChild(columnEnum.Current);
                    previousColumn = columnEnum.Current;
                }
                nextToken = previousColumn.Position.endTokenNumber;
            }
            return(nextToken);
        }
예제 #3
0
        private List <RawTableJoinRow> ResultBatch2RowList(Table table,
                                                           MemoryDbDataReader.ResultBatch batch, SqlIdentifierCollection columnList = null)
        {
            var rowList = new List <RawTableJoinRow>( );

            foreach (var row in batch.ResultRows)
            {
                var tableRow = new RawTableRow
                {
                    Name  = table.FullName,
                    Table = table,
                    Row   = row
                };
                var rows = new RawTableJoinRow( )
                {
                    tableRow
                };
                rowList.Add(rows);
            }

            return(rowList);
        }