Skip to content

IDatabaseUniqueConstraintMethods

Namespace: MJCZone.DapperMatic.Interfaces

Assembly: MJCZone.DapperMatic

Summary

Provides database primary key 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 (11)

Methods

MethodSummary
CreateUniqueConstraintIfNotExistsAsyncCreates a unique constraint if it does not already exist.
CreateUniqueConstraintIfNotExistsAsyncCreates a unique constraint if it does not already exist.
DoesUniqueConstraintExistOnColumnAsyncChecks if a unique constraint exists on a column.
DoesUniqueConstraintExistAsyncChecks if a unique constraint exists.
GetUniqueConstraintOnColumnAsyncGets the unique constraint on a column.
GetUniqueConstraintAsyncGets the unique constraint.
GetUniqueConstraintsAsyncGets the unique constraints.
GetUniqueConstraintNameOnColumnAsyncGets the unique constraint name on a column.
GetUniqueConstraintNamesAsyncGets the unique constraint names.
DropUniqueConstraintOnColumnIfExistsAsyncDrops the unique constraint on a column if it exists.
DropUniqueConstraintIfExistsAsyncDrops the unique constraint if it exists.

CreateUniqueConstraintIfNotExistsAsync

Creates a unique constraint if it does not already exist.

csharp
Task<bool> CreateUniqueConstraintIfNotExistsAsync(
    IDbConnection db,
    DmUniqueConstraint constraint,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters

  • db (IDbConnection) - The database connection.
  • constraint (DmUniqueConstraint) - The unique constraint to create.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint was created, otherwise false.

CreateUniqueConstraintIfNotExistsAsync

Creates a unique constraint if it does not already exist.

csharp
Task<bool> CreateUniqueConstraintIfNotExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string constraintName,
    DmOrderedColumn[] columns,
    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.
  • columns (DmOrderedColumn[]) - The columns included in the constraint.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint was created, otherwise false.

DoesUniqueConstraintExistOnColumnAsync

Checks if a unique constraint exists on a column.

csharp
Task<bool> DoesUniqueConstraintExistOnColumnAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint exists, otherwise false.

DoesUniqueConstraintExistAsync

Checks if a unique constraint exists.

csharp
Task<bool> DoesUniqueConstraintExistAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint exists, otherwise false.

GetUniqueConstraintOnColumnAsync

Gets the unique constraint on a column.

csharp
Task<DmUniqueConstraint?> GetUniqueConstraintOnColumnAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<DmUniqueConstraint?>

The unique constraint if it exists, otherwise null.

GetUniqueConstraintAsync

Gets the unique constraint.

csharp
Task&lt;DmUniqueConstraint?&gt; GetUniqueConstraintAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<DmUniqueConstraint?>

The unique constraint if it exists, otherwise null.

GetUniqueConstraintsAsync

Gets the unique constraints.

csharp
Task&lt;List&lt;DmUniqueConstraint&gt;&gt; GetUniqueConstraintsAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<List<DmUniqueConstraint>>

A list of unique constraints.

GetUniqueConstraintNameOnColumnAsync

Gets the unique constraint name on a column.

csharp
Task&lt;string?&gt; GetUniqueConstraintNameOnColumnAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;string?&gt;

The unique constraint name if it exists, otherwise null.

GetUniqueConstraintNamesAsync

Gets the unique constraint names.

csharp
Task&lt;List&lt;string&gt;&gt; GetUniqueConstraintNamesAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

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

A list of unique constraint names.

DropUniqueConstraintOnColumnIfExistsAsync

Drops the unique constraint on a column if it exists.

csharp
Task&lt;bool&gt; DropUniqueConstraintOnColumnIfExistsAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;bool&gt;

True if the constraint was dropped, otherwise false.

DropUniqueConstraintIfExistsAsync

Drops the unique constraint if it exists.

csharp
Task&lt;bool&gt; DropUniqueConstraintIfExistsAsync(
    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 database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;bool&gt;

True if the constraint was dropped, otherwise false.