示例#1
0
        public async Task CreateAsync(AzureDatabaseTierDetails azureDetails = null)
        {
            using (var connection = await SqlConnectionFactory.CreateAndOpenAsync(_builder.CloneForMaster().ConnectionString))
                using (var command = new SqlCommand(Commands.Database_Create, connection))
                {
                    if (azureDetails != null && await _server.IsAzureAsync())
                    {
                        if (!string.IsNullOrWhiteSpace(azureDetails.ElasticPool))
                        {
                            command.CommandText = Commands.Database_Create_Azure_Pool
                                                  .Replace("@ElasticPool", azureDetails.ElasticPool);
                        }
                        else
                        {
                            command.CommandText = Commands.Database_Create_Azure_Single
                                                  .Replace("@Edition", azureDetails.Edition)
                                                  .Replace("@ServiceObjective", azureDetails.ServiceObjective);
                        }
                    }
                    command.CommandText = command.CommandText.Replace("@Database", _builder.InitialCatalog);

                    await command.ExecuteNonQueryAsync();
                }
        }