Beispiel #1
0
        public async Task <RowProvider> BuildTree(Sql.DmlDdlSqlStatement statement, ITransaction tran, InputStringNormalizer _)
        {
            if (!statement.IsCreate)
            {
                throw new ArgumentException();
            }

            Sql.DmlDdlSqlStatement.Create createStatement = (Sql.DmlDdlSqlStatement.Create)statement;
            string tableName = createStatement.Item.Table;
            var    columns   = createStatement.Item.ColumnList.ToList();

            MetadataTablesManager tableManager = this.metadataManager.GetTableManager();

            TableCreateDefinition tableCreateDefinition = new TableCreateDefinition();

            tableCreateDefinition.TableName   = tableName;
            tableCreateDefinition.ColumnNames = columns.Select(c => c.Item3).ToArray();
            tableCreateDefinition.ColumnTypes = columns.Select(c =>
            {
                if (c.Item1.IsDoubleCType)
                {
                    return(new ColumnInfo(ColumnType.Double));
                }
                else if (c.Item1.IsIntCType)
                {
                    return(new ColumnInfo(ColumnType.Int));
                }
                else if (c.Item1.IsStringCType)
                {
                    if (c.Item2 > MAX_STRING_LENGTH)
                    {
                        throw new ArgumentException("String too big.");
                    }

                    return(new ColumnInfo(ColumnType.String, c.Item2));
                }
                else
                {
                    throw new ArgumentException();
                }
            }).ToArray();

            await tableManager.CreateObject(tableCreateDefinition, tran).ConfigureAwait(false);

            return(new RowProvider(TaskExtension.EmptyEnumerable <RowHolder>(), new MetadataColumn[0]));
        }
Beispiel #2
0
 public IAsyncEnumerator <T> GetAsyncEnumerator(CancellationToken cancellationToken = default)
 {
     return(TaskExtension.EmptyEnumerator <T>());
 }