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 ​
Method | Summary |
---|---|
CreateUniqueConstraintIfNotExistsAsync | Creates a unique constraint if it does not already exist. |
CreateUniqueConstraintIfNotExistsAsync | Creates a unique constraint if it does not already exist. |
DoesUniqueConstraintExistOnColumnAsync | Checks if a unique constraint exists on a column. |
DoesUniqueConstraintExistAsync | Checks if a unique constraint exists. |
GetUniqueConstraintOnColumnAsync | Gets the unique constraint on a column. |
GetUniqueConstraintAsync | Gets the unique constraint. |
GetUniqueConstraintsAsync | Gets the unique constraints. |
GetUniqueConstraintNameOnColumnAsync | Gets the unique constraint name on a column. |
GetUniqueConstraintNamesAsync | Gets the unique constraint names. |
DropUniqueConstraintOnColumnIfExistsAsync | Drops the unique constraint on a column if it exists. |
DropUniqueConstraintIfExistsAsync | Drops the unique constraint if it exists. |
CreateUniqueConstraintIfNotExistsAsync ​
Creates a unique constraint if it does not already exist.
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.
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.
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.
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.
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.
Task<DmUniqueConstraint?> 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.
Task<List<DmUniqueConstraint>> 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.
Task<string?> 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<string?>
The unique constraint name if it exists, otherwise null.
GetUniqueConstraintNamesAsync ​
Gets the unique constraint names.
Task<List<string>> 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<List<string>>
A list of unique constraint names.
DropUniqueConstraintOnColumnIfExistsAsync ​
Drops the unique constraint on a column if it exists.
Task<bool> 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<bool>
True if the constraint was dropped, otherwise false.
DropUniqueConstraintIfExistsAsync ​
Drops the unique constraint if it exists.
Task<bool> 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<bool>
True if the constraint was dropped, otherwise false.