public async Task CreateFromSqlAsync(string createStatements)
        {
            logger.Trace($"CreateFromTextAsync():createStatements={createStatements}");
            var noCommentSql = SQL_COMMENT.Replace(createStatements, "");
            var sqlParts     = noCommentSql.Split(';').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x));

            List <string> tableSchemasToLoad = new List <string>();

            using (var transaction = await this.BeginTransactionAsync() as BaseTransaction) {
                foreach (var sqlPart in sqlParts)
                {
                    if (!string.IsNullOrWhiteSpace(sqlPart))
                    {
                        CreateStatement statement = this.CreateStatement(sqlPart);
                        if (!this.TableByName.Keys.Contains(statement.TableName))
                        {
                            bool tableSchemaLoaded = await transaction.CreateAsync(statement);

                            if (!tableSchemaLoaded)
                            {
                                tableSchemasToLoad.Add(statement.TableName);
                            }
                        }
                    }
                }
                await transaction.CommitAsync();
            }

            foreach (var tableName in tableSchemasToLoad)
            {
                Table table = await this.LoadTableSchemaAsync(tableName);

                this.tableByName[table.Name] = table;
            }
        }
Example #2
0
 protected abstract Task <bool> DoCreateAsync(CreateStatement statement);
Example #3
0
 protected abstract bool DoCreate(CreateStatement statement);
Example #4
0
 public async Task <bool> CreateAsync(CreateStatement statement)
 {
     return(await this.DoCreateAsync(statement));
 }
Example #5
0
 // Create methods
 public bool Create(CreateStatement statement)
 {
     return(this.DoCreate(statement));
 }