Skip to content

IDatabasePrimaryKeyConstraintMethods ​

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 (5)

Methods ​

CreatePrimaryKeyConstraintIfNotExistsAsync ​

Creates a primary key constraint if it does not already exist.

csharp
Task<bool> CreatePrimaryKeyConstraintIfNotExistsAsync(IDbConnection db, DmPrimaryKeyConstraint constraint, IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

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

Returns ​

Type: Task<bool>

A task that represents the asynchronous operation. The task result contains a boolean indicating whether the constraint was created.

CreatePrimaryKeyConstraintIfNotExistsAsync ​

Creates a primary key constraint if it does not already exist.

csharp
Task<bool> CreatePrimaryKeyConstraintIfNotExistsAsync(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 that make up the primary key.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

A task that represents the asynchronous operation. The task result contains a boolean indicating whether the constraint was created.

DoesPrimaryKeyConstraintExistAsync ​

Checks if a primary key constraint exists.

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

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

A task that represents the asynchronous operation. The task result contains a boolean indicating whether the constraint exists.

GetPrimaryKeyConstraintAsync ​

Gets the primary key constraint.

csharp
Task<DmPrimaryKeyConstraint?> GetPrimaryKeyConstraintAsync(IDbConnection db, string schemaName, string tableName, IDbTransaction tx, CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<DmPrimaryKeyConstraint?>

A task that represents the asynchronous operation. The task result contains the primary key constraint.

DropPrimaryKeyConstraintIfExistsAsync ​

Drops a primary key constraint if it exists.

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

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • tx (IDbTransaction) - The database transaction.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task<bool>

A task that represents the asynchronous operation. The task result contains a boolean indicating whether the constraint was dropped.