예제 #1
0
 public string GetProperty(string propertyName)
 {
     using (var connection = SqlConnectionFactory.CreateAndOpen(_builder.CloneForMaster().ConnectionString))
         using (var command = new SqlCommand(Commands.Server_Property_Get, connection))
         {
             command.Parameters.AddWithValue("@Property", propertyName);
             var reader = command.ExecuteReader();
             return(reader.Read() ? reader[0].ToString() : null);
         }
 }
예제 #2
0
 public ISqlDatabase this[string database]
 {
     get
     {
         if (string.IsNullOrWhiteSpace(database))
         {
             throw new ArgumentNullException(nameof(database), "Database name cannot be null or whitespace.");
         }
         return(new SqlDatabase(_builder.CloneForMaster()));
     }
 }
예제 #3
0
        public void Create(AzureDatabaseTierDetails azureDetails = null)
        {
            using (var connection = SqlConnectionFactory.CreateAndOpen(_builder.CloneForMaster().ConnectionString))
                using (var command = new SqlCommand(Commands.Database_Create, connection))
                {
                    if (azureDetails != null && _server.IsAzure())
                    {
                        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);

                    command.ExecuteNonQuery();
                }
        }