SqlServerSchemaProvisioner

Implements an ISchemaProvisioner for Microsoft SQL server.

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

Constructors

SqlServerSchemaProvisioner

Default constructor

Signature:
public Void SqlServerSchemaProvisioner()

Properties

CommandBuilder

Database command builder.

Signature:
public IDbCmdBuilder CommandBuilder { get; set; }

DataAccessAPI

Database access.

Signature:
public IDbAccess DataAccessAPI { get; set; }

Methods

AddColumnAsync

Adds a column to a table.

Signature:
public Task AddColumnAsync(table, column)
Parameters
Name Type Summary
table Table Table to be altered.
column TableColumn Column to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

ValidationException Thrown when the configuration is not valid.

AddColumnConstraintAsync

Adds a column constraint.

Signature:
public Task AddColumnConstraintAsync(table, column, constraint)
Parameters
Name Type Summary
table Table Table to be alter.
column TableColumn Column to be alter.
constraint ColumnConstraint Contraint to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

-or- constraint is null.

ValidationException Thrown when the configuration is not valid.

AddForeignKeyAsync

Adds a foreign key to table.

Signature:
public Task AddForeignKeyAsync(table, foreignKey)
Parameters
Name Type Summary
table Table Table to be alter.
foreignKey ForeignKey Foreign key to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- foreignKey is null.

ValidationException Thrown when the configuration is not valid.

AlterColumnAsync

Modifies a table column.

Signature:
public Task AlterColumnAsync(table, from, to)
Parameters
Name Type Summary
table Table Table to be alter.
from TableColumn The actual configuration of the column.
to TableColumn The desired configuration of the column.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- from is null.

-or- to is null.

ValidationException Thrown when the configuration is not valid.

CreateIndexAsync

Creates an index.

Signature:
public Task CreateIndexAsync(table, index)
Parameters
Name Type Summary
table Table Table to be alter.
index Index Index to be created.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- index is null.

ValidationException Thrown when the configuration is not valid.

CreatePrimaryKeyAsync

Creates a primary key for the table.

Signature:
public Task CreatePrimaryKeyAsync(table, primaryKey)
Parameters
Name Type Summary
table Table Table to be alter.
primaryKey Index Primary key to be created.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- primaryKey is null.

ValidationException Thrown when the configuration is not valid.

CreateSequenceIfNotExistsAsync

Creates a sequence if it does not exists.

Signature:
public Task CreateSequenceIfNotExistsAsync(sequence)
Remarks

Sql Server does not support sequences so this method does nothing.

Parameters
Name Type Summary
sequence Sequence A sequence to be created.

CreateTableAsync

Creates a table.

Signature:
public Task CreateTableAsync(table)
Parameters
Name Type Summary
table Table Table to be created.
Exceptions
Type Summary
ArgumentNullException Thrown when table is null.
ValidationException Thrown when the configuration is not valid.

CreateViewAsync

Creates a view.

Signature:
public Task CreateViewAsync(view)
Parameters
Name Type Summary
view View View to be created.
Exceptions
Type Summary
ArgumentNullException Thrown when view is null.
ValidationException Thrown when the configuration is not valid.

DropColumnAsync

Drops a column from the table.

Signature:
public Task DropColumnAsync(table, column)
Parameters
Name Type Summary
table Table Table to alter.
column TableColumn Column to be dropped.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

ValidationException Thrown when the configuration is not valid.

DropColumnConstraintAsync

Drops a column constraint.

Signature:
public Task DropColumnConstraintAsync(table, column, constraint)
Parameters
Name Type Summary
table Table Table to alter.
column TableColumn Column to alter.
constraint ColumnConstraint Contraint to be dropped.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

-or- constraint is null.

ValidationException Thrown when the configuration is not valid.

DropForeignKeyAsync

Drops a foreign key.

Signature:
public Task DropForeignKeyAsync(table, foreignKey)
Parameters
Name Type Summary
table Table Table to alter.
foreignKey ForeignKey Foreign key to drop.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- foreignKey is null.

ValidationException Thrown when the configuration is not valid.

DropIndexAsync

Drops an index.

Signature:
public Task DropIndexAsync(table, index)
Parameters
Name Type Summary
table Table Table to alter.
index Index Index to drop.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- index is null.

ValidationException Thrown when the configuration is not valid.

DropPrimaryKeyAsync

Drops a primary key index.

Signature:
public Task DropPrimaryKeyAsync(table, primaryKey)
Parameters
Name Type Summary
table Table Table to alter.
primaryKey Index Index to drop.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- primaryKey is null.

ValidationException Thrown when the configuration is not valid.

DropTableAsync

Drops a table.

Signature:
public Task DropTableAsync(table)
Parameters
Name Type Summary
table Table Table to drop.
Exceptions
Type Summary
ArgumentNullException Thrown when table is null.
ValidationException Thrown when the configuration is not valid.

DropViewAsync

Drops a view.

Signature:
public Task DropViewAsync(view)
Parameters
Name Type Summary
view View View to drop.
Exceptions
Type Summary
ArgumentNullException Thrown when view is null.
ValidationException Thrown when the configuration is not valid.

GrantPermissionsAsync

Grants permission to a grantee to access a database object.

Signature:
public Task GrantPermissionsAsync(grant)
Remarks

This method does nothing for Sql Server.

Parameters
Name Type Summary
grant Grant Grant configuration.

RenameTableAsync

Renames a table.

Signature:
public Task RenameTableAsync(tableName, newTableName)
Parameters
Name Type Summary
tableName TableName Name of the table to be renamed.
newTableName String New table name.
Exceptions
Type Summary
ArgumentNullException Thrown when tableName is null.
ArgumentNullOrEmptyException Thrown when newTableName is null or empty.
ValidationException Thrown when the configuration is not valid.

ValidateColumnConstraintForAdd

Validates the arguments for adding a constraint to a column.

Signature:
public Void ValidateColumnConstraintForAdd(table, column, constraint)
Parameters
Name Type Summary
table Table Table to be alter.
column TableColumn Column to be alter.
constraint ColumnConstraint Contraint to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

-or- constraint is null.

ValidationException Thrown when the configuration is not valid.

ValidateColumnConstraintForDrop

Validates the arguments for dropping a column constraint.

Signature:
public Void ValidateColumnConstraintForDrop(table, column, constraint)
Parameters
Name Type Summary
table Table Table to alter.
column TableColumn Column to alter.
constraint ColumnConstraint Contraint to be dropped.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

-or- constraint is null.

ValidationException Thrown when the configuration is not valid.

ValidateForeignKeyForAdd

Validates the arguments for adding a foreign key to a table.

Signature:
public Void ValidateForeignKeyForAdd(table, foreignKey)
Parameters
Name Type Summary
table Table Table to be alter.
foreignKey ForeignKey Foreign key to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- foreignKey is null.

ValidationException Thrown when the configuration is not valid.

ValidateForeignKeyForDrop

Validates the arguments for dropping a foreign key.

Signature:
public Void ValidateForeignKeyForDrop(table, foreignKey)
Parameters
Name Type Summary
table Table Table to alter.
foreignKey ForeignKey Foreign key to drop.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- foreignKey is null.

ValidationException Thrown when the configuration is not valid.

ValidateGrantForGrant

Validates the argument for grant permissions.

Signature:
public Void ValidateGrantForGrant(grant)
Remarks

This method does nothing for Sql Server.

Parameters
Name Type Summary
grant Grant Grant configuration.

ValidateIndexForCreate

Validate the arguments for creating an index.

Signature:
public Void ValidateIndexForCreate(table, index)
Parameters
Name Type Summary
table Table Table to be alter.
index Index Index to be created.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- index is null.

ValidationException Thrown when the configuration is not valid.

ValidateIndexForDrop

Validates the arguments for dropping an index.

Signature:
public Void ValidateIndexForDrop(table, index)
Parameters
Name Type Summary
table Table Table to alter.
index Index Index to drop.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- index is null.

ValidationException Thrown when the configuration is not valid.

ValidateSequenceForCreate

Validates the arguments for creating a sequence.

Signature:
public Void ValidateSequenceForCreate(sequence)
Remarks

Sql Server does not support sequences so this method does nothing.

Parameters
Name Type Summary
sequence Sequence A sequence to be created.

ValidateTableColumnForAdd

Validates the arguments for adding a column to a table.

Signature:
public Void ValidateTableColumnForAdd(table, column)
Parameters
Name Type Summary
table Table Table to be altered.
column TableColumn Column to be added.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

ValidationException Thrown when the configuration is not valid.

ValidateTableColumnForAlter

Validates the arguments for modifying a table column.

Signature:
public Void ValidateTableColumnForAlter(table, from, to)
Parameters
Name Type Summary
table Table Table to be alter.
from TableColumn The actual configuration of the column.
to TableColumn The desired configuration of the column.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- from is null.

-or- to is null.

ValidationException Thrown when the configuration is not valid.

ValidateTableColumnForDrop

Validates the argument for dropping a column.

Signature:
public Void ValidateTableColumnForDrop(table, column)
Parameters
Name Type Summary
table Table Table to alter.
column TableColumn Column to be dropped.
Exceptions
Type Summary
ArgumentNullException

Thrown when table is null.

-or- column is null.

ValidationException Thrown when the configuration is not valid.

ValidateTableForCreate

Validates the argument for creating a table.

Signature:
public Void ValidateTableForCreate(table)
Parameters
Name Type Summary
table Table Table to be created.
Exceptions
Type Summary
ArgumentNullException Thrown when table is null.
ValidationException Thrown when the configuration is not valid.

ValidateTableForDrop

Validates the argument for dropping a table.

Signature:
public Void ValidateTableForDrop(table)
Parameters
Name Type Summary
table Table Table to drop.
Exceptions
Type Summary
ArgumentNullException Thrown when table is null.
ValidationException Thrown when the configuration is not valid.

ValidateViewForCreate

Validates the argument for creating a view.

Signature:
public Void ValidateViewForCreate(view)
Parameters
Name Type Summary
view View View to be created.
Exceptions
Type Summary
ArgumentNullException Thrown when view is null.
ValidationException Thrown when the configuration is not valid.

ValidateViewForDrop

Validates the argument for dropping a view.

Signature:
public Void ValidateViewForDrop(view)
Parameters
Name Type Summary
view View View to drop.
Exceptions
Type Summary
ArgumentNullException Thrown when view is null.
ValidationException Thrown when the configuration is not valid.