Skip to content

IDatabaseCheckConstraintMethods ​

Namespace: MJCZone.DapperMatic.Interfaces

Assembly: MJCZone.DapperMatic

Summary ​

Provides database check constraint methods for database operations.

abstract public

Note: This is an interface that defines a contract. Look for implementing classes in the same or related namespaces.

Contents ​

Methods (12)

Methods ​

MethodSummary
CreateCheckConstraintIfNotExistsAsyncCreates a check constraint if it does not already exist.
CreateCheckConstraintIfNotExistsAsyncCreates a check constraint if it does not already exist.
DoesCheckConstraintExistOnColumnAsyncChecks if a check constraint exists on a column.
DoesCheckConstraintExistAsyncChecks if a check constraint exists.
GetCheckConstraintOnColumnAsyncGets the check constraint on a column.
GetCheckConstraintAsyncGets the check constraint.
GetCheckConstraintsAsyncGets a list of check constraints.
GetCheckConstraintNameOnColumnAsyncGets the name of the check constraint on a column.
GetCheckConstraintNamesAsyncGets a list of check constraint names.
DropCheckConstraintOnColumnIfExistsAsyncDrops a check constraint on a column if it exists.
DropCheckConstraintIfExistsAsyncDrops a check constraint if it exists.
RenameCheckConstraintIfExistsAsyncRenames a check constraint if it exists.

CreateCheckConstraintIfNotExistsAsync ​

Creates a check constraint if it does not already exist.

csharp
Task<bool> CreateCheckConstraintIfNotExistsAsync(
    IDbConnection db,
    DmCheckConstraint constraint,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • constraint (DmCheckConstraint) - The check constraint to create.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

True if the constraint was created, false otherwise.

CreateCheckConstraintIfNotExistsAsync ​

Creates a check constraint if it does not already exist.

csharp
Task<bool> CreateCheckConstraintIfNotExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    string constraintName,
    string expression,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • columnName (string) - The column name.
  • constraintName (string) - The constraint name.
  • expression (string) - The constraint expression.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

True if the constraint was created, false otherwise.

DoesCheckConstraintExistOnColumnAsync ​

Checks if a check constraint exists on a column.

csharp
Task<bool> DoesCheckConstraintExistOnColumnAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • columnName (string) - The column name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

True if the constraint exists, false otherwise.

DoesCheckConstraintExistAsync ​

Checks if a check constraint exists.

csharp
Task<bool> DoesCheckConstraintExistAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintName (string) - The constraint name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

True if the constraint exists, false otherwise.

GetCheckConstraintOnColumnAsync ​

Gets the check constraint on a column.

csharp
Task<DmCheckConstraint?> GetCheckConstraintOnColumnAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • columnName (string) - The column name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<DmCheckConstraint?>

The check constraint, or null if it does not exist.

GetCheckConstraintAsync ​

Gets the check constraint.

csharp
Task&lt;DmCheckConstraint?&gt; GetCheckConstraintAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintName (string) - The constraint name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<DmCheckConstraint?>

The check constraint, or null if it does not exist.

GetCheckConstraintsAsync ​

Gets a list of check constraints.

csharp
Task&lt;List&lt;DmCheckConstraint&gt;&gt; GetCheckConstraintsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintNameFilter,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintNameFilter (string) - The constraint name filter.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<List<DmCheckConstraint>>

A list of check constraints.

GetCheckConstraintNameOnColumnAsync ​

Gets the name of the check constraint on a column.

csharp
Task&lt;string?&gt; GetCheckConstraintNameOnColumnAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • columnName (string) - The column name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;string?&gt;

The name of the check constraint, or null if it does not exist.

GetCheckConstraintNamesAsync ​

Gets a list of check constraint names.

csharp
Task&lt;List&lt;string&gt;&gt; GetCheckConstraintNamesAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintNameFilter,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintNameFilter (string) - The constraint name filter.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;List&lt;string&gt;&gt;

A list of check constraint names.

DropCheckConstraintOnColumnIfExistsAsync ​

Drops a check constraint on a column if it exists.

csharp
Task&lt;bool&gt; DropCheckConstraintOnColumnIfExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • columnName (string) - The column name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if the constraint was dropped, false otherwise.

DropCheckConstraintIfExistsAsync ​

Drops a check constraint if it exists.

csharp
Task&lt;bool&gt; DropCheckConstraintIfExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintName (string) - The constraint name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if the constraint was dropped, false otherwise.

RenameCheckConstraintIfExistsAsync ​

Renames a check constraint if it exists.

csharp
Task&lt;bool&gt; RenameCheckConstraintIfExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintName,
    string newConstraintName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • constraintName (string) - The current name.
  • newConstraintName (string) - The new name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if it was renamed; false if it does not exist, or the new name is already taken.