Operations: Server: How to delete a database?

This operation is used to delete databases from a server, with a possibility to remove all the data from hard drive.

Syntax

public DeleteDatabasesOperation(
    string databaseName,
    bool hardDelete,
    string fromNode = null,
    TimeSpan? timeToWaitForConfirmation = null)
{
}

public DeleteDatabasesOperation(DeleteDatabasesOperation.Parameters parameters)
{
}

public class Parameters
{
    public string[] DatabaseNames { get; set; }

    public bool HardDelete { get; set; }

    public string[] FromNodes { get; set; }

    public TimeSpan? TimeToWaitForConfirmation { get; set; }
}
Parameters
DatabaseName string Name of a database to delete
HardDelete bool Should all data be removed (data files, indexing files, etc.).
FromNode string Remove the database just from a specific node. Default: null which would delete from all
TimeToWaitForConfirmation TimeSpan Time to wait for confirmation. Default: null will user server default (15 seconds)

Example I

var parameters = new DeleteDatabasesOperation.Parameters
{
    DatabaseNames = new[] { "MyNewDatabase", "OtherDatabaseToDelete" },
    HardDelete = true,
    FromNodes = new[] { "A", "C" },     // optional
    TimeToWaitForConfirmation = TimeSpan.FromSeconds(30)    // optional
};
store.Maintenance.Server.Send(new DeleteDatabasesOperation(parameters));
var parameters = new DeleteDatabasesOperation.Parameters
{
    DatabaseNames = new[] { "MyNewDatabase", "OtherDatabaseToDelete" },
    HardDelete = true,
    FromNodes = new[] { "A", "C" },   // optional
    TimeToWaitForConfirmation = TimeSpan.FromSeconds(30)    // optional
};
await store.Maintenance.Server.SendAsync(new DeleteDatabasesOperation(parameters));

Example II

In order to delete just one database from a server, you can also use this simplified constructor

store.Maintenance.Server.Send(new DeleteDatabasesOperation("MyNewDatabase", hardDelete: true, fromNode: null, timeToWaitForConfirmation: null));
await store.Maintenance.Server.SendAsync(new DeleteDatabasesOperation("MyNewDatabase", hardDelete: true, fromNode: null, timeToWaitForConfirmation: null));