Table of Contents

Class SqlDatabaseCommitVersionsContext

Namespace
LfrlAnvil.Sql.Internal
Assembly
LfrlAnvil.Sql.Core.dll

Represents an object used for managing application of versions to the database.

public class SqlDatabaseCommitVersionsContext : IDisposable
Inheritance
SqlDatabaseCommitVersionsContext
Implements
Inherited Members

Constructors

SqlDatabaseCommitVersionsContext()

Creates a new SqlDatabaseCommitVersionsContext instance.

protected SqlDatabaseCommitVersionsContext()

Methods

AddCommandParameter(DbCommand, SqlColumnBuilder)

Adds a DB parameter to the provided command based on the column definition.

protected static void AddCommandParameter(DbCommand command, SqlColumnBuilder column)

Parameters

command DbCommand

DB command to add a DB parameter to.

column SqlColumnBuilder

SQL column builder to use for initializing the DB parameter.

Dispose()

public virtual void Dispose()

GetVersionHistoryColumnType(string)

Returns an SqlColumnTypeDefinition of a version history table's column with the provided name.

[Pure]
protected SqlColumnTypeDefinition GetVersionHistoryColumnType(string name)

Parameters

name string

Name of the column.

Returns

SqlColumnTypeDefinition

SqlColumnTypeDefinition of a version history table's column with the provided name.

Exceptions

KeyNotFoundException

When version history table column with the provided name does not exist.

OnAfterVersionActionRangeExecution(SqlDatabaseBuilder, SqlDatabaseFactoryStatementKey, DbCommand, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just after a range of SQL statements prepared for a single applied version has been executed.

protected virtual SqlDatabaseFactoryStatementKey OnAfterVersionActionRangeExecution(SqlDatabaseBuilder builder, SqlDatabaseFactoryStatementKey key, DbCommand command, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

key SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last SQL statement of the applied version.

command DbCommand

DB command that executed all statements.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

Returns

SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last ran SQL statement of the applied version.

OnAfterVersionRangeApplication(SqlDatabaseBuilder, DbConnection, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just after the processing of all versions to apply has finished.

protected virtual void OnAfterVersionRangeApplication(SqlDatabaseBuilder builder, DbConnection connection, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

connection DbConnection

Opened connection to the database.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

OnAfterVersionTransaction(SqlDatabaseBuilder, SqlDatabaseFactoryStatementKey, DbConnection, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just after a DB transaction for a single applied version is committed.

protected virtual void OnAfterVersionTransaction(SqlDatabaseBuilder builder, SqlDatabaseFactoryStatementKey key, DbConnection connection, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

key SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last SQL statement of the applied version.

connection DbConnection

Opened connection to the database.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

OnBeforeVersionActionRangeExecution(SqlDatabaseBuilder, SqlDatabaseFactoryStatementKey, DbCommand, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just before a range of SQL statements prepared for a single applied version is executed.

protected virtual SqlDatabaseFactoryStatementKey OnBeforeVersionActionRangeExecution(SqlDatabaseBuilder builder, SqlDatabaseFactoryStatementKey key, DbCommand command, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

key SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last SQL statement of the applied version.

command DbCommand

DB command that will execute all statements.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

Returns

SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last ran SQL statement of the applied version.

OnBeforeVersionRangeApplication(SqlDatabaseBuilder, DbConnection, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just before the processing of all versions to apply starts.

protected virtual void OnBeforeVersionRangeApplication(SqlDatabaseBuilder builder, DbConnection connection, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

connection DbConnection

Opened connection to the database.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

OnBeforeVersionTransaction(SqlDatabaseBuilder, SqlDatabaseFactoryStatementKey, DbConnection, ref SqlDatabaseFactoryStatementExecutor)

Callback invoked just before a DB transaction for a single applied version is created.

protected virtual SqlDatabaseFactoryStatementKey OnBeforeVersionTransaction(SqlDatabaseBuilder builder, SqlDatabaseFactoryStatementKey key, DbConnection connection, ref SqlDatabaseFactoryStatementExecutor executor)

Parameters

builder SqlDatabaseBuilder

SQL database builder.

key SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last SQL statement of the applied version.

connection DbConnection

Opened connection to the database.

executor SqlDatabaseFactoryStatementExecutor

Decorator for executing SQL statements on the database.

Returns

SqlDatabaseFactoryStatementKey

SqlDatabaseFactoryStatementKey instance that identifies the last ran SQL statement of the applied version.

PrepareDeleteAllVersionHistoryRecordsCommand(DbCommand, SqlTableBuilder, SqlNodeInterpreter)

Prepares a DB command responsible for removing all records from the version history table.

protected virtual void PrepareDeleteAllVersionHistoryRecordsCommand(DbCommand command, SqlTableBuilder table, SqlNodeInterpreter nodeInterpreter)

Parameters

command DbCommand

DB command to prepare.

table SqlTableBuilder

SQL table builder for the version history table.

nodeInterpreter SqlNodeInterpreter

SQL node interpreter instance.

PrepareInsertVersionHistoryRecordCommand(DbCommand, SqlTableBuilder, SqlNodeInterpreter)

Prepares a DB command responsible for inserting a single record into the version history table.

protected virtual void PrepareInsertVersionHistoryRecordCommand(DbCommand command, SqlTableBuilder table, SqlNodeInterpreter nodeInterpreter)

Parameters

command DbCommand

DB command to prepare.

table SqlTableBuilder

SQL table builder for the version history table.

nodeInterpreter SqlNodeInterpreter

SQL node interpreter instance.

PrepareUpdateVersionHistoryRecordCommand(DbCommand, SqlTableBuilder, SqlNodeInterpreter)

Prepares a DB command responsible for updating a single record in the version history table.

protected virtual void PrepareUpdateVersionHistoryRecordCommand(DbCommand command, SqlTableBuilder table, SqlNodeInterpreter nodeInterpreter)

Parameters

command DbCommand

DB command to prepare.

table SqlTableBuilder

SQL table builder for the version history table.

nodeInterpreter SqlNodeInterpreter

SQL node interpreter instance.

SetInsertVersionHistoryRecordCommandParameters(DbParameterCollection, int, Version, string)

Prepares values of DB parameters of a command responsible for inserting a single record into the version history table.

protected virtual void SetInsertVersionHistoryRecordCommandParameters(DbParameterCollection parameters, int ordinal, Version version, string description)

Parameters

parameters DbParameterCollection

Collection of DB parameters.

ordinal int

Ordinal of the record to insert.

version Version

Identifier of the applied version.

description string

Description of the applied version.

SetUpdateVersionHistoryRecordCommandParameters(DbParameterCollection, int, TimeSpan)

Prepares values of DB parameters of a command responsible for updating a single record in the version history table.

protected virtual void SetUpdateVersionHistoryRecordCommandParameters(DbParameterCollection parameters, int ordinal, TimeSpan elapsedTime)

Parameters

parameters DbParameterCollection

Collection of DB parameters.

ordinal int

Ordinal of the record to update.

elapsedTime TimeSpan

Specifies the time it took to fully apply the version to the database.