SqlServerDbaServices

Provides DBA services for Microsoft SQL Server.

Namespace:
Inetdev.Data.SqlServer.Dba
Type:
Class
Public:
Yes
Protected:
No
Sealed:
Yes
Abstract:
No
Inherits from:
System.Object

Constructors

SqlServerDbaServices

Default constructor

Signature:
public Void SqlServerDbaServices()

Properties

DataAccessAPI

Database communication API pointing to the "master" database.

Signature:
public IDbAccess DataAccessAPI { get; set; }

Formatter

An IDbFormatter for Sql Server.

Signature:
public IDbFormatter Formatter { get; set; }

Methods

ChangeLoginPasswordAsync

Changes the login password.

Signature:
public Task ChangeLoginPasswordAsync(login)
Parameters
Name Type Summary
login Login A Login to create.
Exceptions
Type Summary
ValidationException Thrown when login does not have the required configuration.
ArgumentNullException Thrown when login is null.
SchemaManipulationException Thrown when an error occurs while manipulating the database.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

CreateDatabaseAsync

Creates a new database.

Signature:
public Task CreateDatabaseAsync(name, collate, autoCloseOff, autoShrinkOff)
Parameters
Name Type Summary
name String Name of the database.
collate String Collation for the database (optional).
autoCloseOff Boolean Whether to issue an AUTO_CLOSE OFF command.
autoShrinkOff Boolean Whether to issue an AUTO_SHRINK OFF command.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

CreateLoginAsync

Creates a new login.

Signature:
public Task CreateLoginAsync(login)
Parameters
Name Type Summary
login Login A Login to create.
Exceptions
Type Summary
ValidationException Thrown when login does not have the required configuration.
ArgumentNullException Thrown when login is null.
SchemaManipulationException Thrown when an error occurs while manipulating the database.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

CreateSchemaAsync

Creates a schema in the database.

Signature:
public Task CreateSchemaAsync(name, database)
Parameters
Name Type Summary
name String Name of the schema.
database String Name of the database.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
ArgumentNullOrEmptyException Thrown when database is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

CreateUserAsync

Creates a user for login in the database database and adds the user to the specified roles.

Signature:
public Task CreateUserAsync(userName, login, database, roles)
Parameters
Name Type Summary
userName String Name of the user to add.
login String Name of the login the user is added for.
database String Name of the database to add the user to.
roles UserRoles User roles to be granted to the new user.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when userName is null or empty.
ArgumentNullOrEmptyException Thrown when login is null or empty.
ArgumentNullOrEmptyException Thrown when database is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

DropDatabaseAsync

Drops a database.

Signature:
public Task DropDatabaseAsync(name)
Parameters
Name Type Summary
name String Name of the database to drop.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

DropLoginAsync

Drops a login.

Signature:
public Task DropLoginAsync(name)
Parameters
Name Type Summary
name String Name of the login to drop.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

DropSchemaAsync

Drops a schema in the database.

Signature:
public Task DropSchemaAsync(name, database)
Parameters
Name Type Summary
name String Name of the schema.
database String Name of the database.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
ArgumentNullOrEmptyException Thrown when database is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

DropUserAsync

Drops a user named name from the database.

Signature:
public Task DropUserAsync(name, database)
Parameters
Name Type Summary
name String Name of the user to drop.
database String Name of the database from where the user is dropped.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
ArgumentNullOrEmptyException Thrown when database is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

ExistsDatabaseAsync

Checks whether a database exists on the server.

Signature:
public Task<Boolean> ExistsDatabaseAsync(name)
Returns

true if the database exists, otherwise false.

Parameters
Name Type Summary
name String Name of the database to check.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while accesing the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

ExistsLoginAsync

Checks whether a login exists.

Signature:
public Task<Boolean> ExistsLoginAsync(name)
Returns

true if the login exists, otherwise false.

Parameters
Name Type Summary
name String Name of the login to check.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while accesing the database.
ArgumentNullOrEmptyException Thrown when name is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

ExistsUserAsync

Checks whether a user exists within a database.

Signature:
public Task<Boolean> ExistsUserAsync(userName, databaseName)
Returns

true if the user exists within the database, otherwise false.

Parameters
Name Type Summary
userName String Name of the user to verify.
databaseName String Name of the database to which the user belongs.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while accesing the database.
ArgumentNullOrEmptyException Thrown when userName is null or empty.
ArgumentNullOrEmptyException Thrown when databaseName is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.

GetServerRolesAsync

Gets the server roles for the spacified userName.

Signature:
public Task<ServerRoles> GetServerRolesAsync(userName)
Returns

A flagged enumeration of the user server roles.

Parameters
Name Type Summary
userName String Name of the user to get it's server roles.
Exceptions
Type Summary
SchemaManipulationException Thrown when an error occurs while manipulating the database.
ArgumentNullOrEmptyException Thrown when userName is null or empty.
MissingRequiredPropertyException Thrown the object was not correctly initialized.