IDatabaseForeignKeyConstraintMethods
Namespace: MJCZone.DapperMatic.Interfaces
Assembly: MJCZone.DapperMatic
Summary
Provides database default 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 |
|---|---|
| CreateForeignKeyConstraintIfNotExistsAsync | Creates a foreign key constraint if it does not already exist. |
| CreateForeignKeyConstraintIfNotExistsAsync | Creates a foreign key constraint if it does not already exist. |
| DoesForeignKeyConstraintExistOnColumnAsync | Checks if a foreign key constraint exists on a column. |
| DoesForeignKeyConstraintExistAsync | Checks if a foreign key constraint exists. |
| GetForeignKeyConstraintOnColumnAsync | Gets the foreign key constraint on a column. |
| GetForeignKeyConstraintAsync | Gets the foreign key constraint. |
| GetForeignKeyConstraintsAsync | Gets the foreign key constraints. |
| GetForeignKeyConstraintNameOnColumnAsync | Gets the foreign key constraint name on a column. |
| GetForeignKeyConstraintNamesAsync | Gets the foreign key constraint names. |
| DropForeignKeyConstraintOnColumnIfExistsAsync | Drops a foreign key constraint on a column if it exists. |
| DropForeignKeyConstraintIfExistsAsync | Drops a foreign key constraint if it exists. |
CreateForeignKeyConstraintIfNotExistsAsync
Creates a foreign key constraint if it does not already exist.
Task<bool> CreateForeignKeyConstraintIfNotExistsAsync(
IDbConnection db,
DmForeignKeyConstraint constraint,
IDbTransaction tx,
CancellationToken cancellationToken)Parameters
- db (IDbConnection) - The database connection.
- constraint (DmForeignKeyConstraint) - The foreign key 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.
CreateForeignKeyConstraintIfNotExistsAsync
Creates a foreign key constraint if it does not already exist.
Task<bool> CreateForeignKeyConstraintIfNotExistsAsync(
IDbConnection db,
string schemaName,
string tableName,
string constraintName,
DmOrderedColumn[] sourceColumns,
string referencedTableName,
DmOrderedColumn[] referencedColumns,
DmForeignKeyAction onDelete,
DmForeignKeyAction onUpdate,
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.
- sourceColumns (DmOrderedColumn[]) - The source columns.
- referencedTableName (string) - The referenced table name.
- referencedColumns (DmOrderedColumn[]) - The referenced columns.
- onDelete (DmForeignKeyAction) - The action on delete.
- onUpdate (DmForeignKeyAction) - The action on update.
- tx (IDbTransaction) - The database transaction.
- cancellationToken (CancellationToken) - The cancellation token.
Returns
Type: Task<bool>
True if the constraint was created, otherwise false.
DoesForeignKeyConstraintExistOnColumnAsync
Checks if a foreign key constraint exists on a column.
Task<bool> DoesForeignKeyConstraintExistOnColumnAsync(
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.
DoesForeignKeyConstraintExistAsync
Checks if a foreign key constraint exists.
Task<bool> DoesForeignKeyConstraintExistAsync(
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.
GetForeignKeyConstraintOnColumnAsync
Gets the foreign key constraint on a column.
Task<DmForeignKeyConstraint?> GetForeignKeyConstraintOnColumnAsync(
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<DmForeignKeyConstraint?>
The foreign key constraint if it exists, otherwise null.
GetForeignKeyConstraintAsync
Gets the foreign key constraint.
Task<DmForeignKeyConstraint?> GetForeignKeyConstraintAsync(
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<DmForeignKeyConstraint?>
The foreign key constraint if it exists, otherwise null.
GetForeignKeyConstraintsAsync
Gets the foreign key constraints.
Task<List<DmForeignKeyConstraint>> GetForeignKeyConstraintsAsync(
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<DmForeignKeyConstraint>>
A list of foreign key constraints.
GetForeignKeyConstraintNameOnColumnAsync
Gets the foreign key constraint name on a column.
Task<string?> GetForeignKeyConstraintNameOnColumnAsync(
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 foreign key constraint name if it exists, otherwise null.
GetForeignKeyConstraintNamesAsync
Gets the foreign key constraint names.
Task<List<string>> GetForeignKeyConstraintNamesAsync(
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 foreign key constraint names.
DropForeignKeyConstraintOnColumnIfExistsAsync
Drops a foreign key constraint on a column if it exists.
Task<bool> DropForeignKeyConstraintOnColumnIfExistsAsync(
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.
DropForeignKeyConstraintIfExistsAsync
Drops a foreign key constraint if it exists.
Task<bool> DropForeignKeyConstraintIfExistsAsync(
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.