Skip to content

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

MethodSummary
CreateForeignKeyConstraintIfNotExistsAsyncCreates a foreign key constraint if it does not already exist.
CreateForeignKeyConstraintIfNotExistsAsyncCreates a foreign key constraint if it does not already exist.
DoesForeignKeyConstraintExistOnColumnAsyncChecks if a foreign key constraint exists on a column.
DoesForeignKeyConstraintExistAsyncChecks if a foreign key constraint exists.
GetForeignKeyConstraintOnColumnAsyncGets the foreign key constraint on a column.
GetForeignKeyConstraintAsyncGets the foreign key constraint.
GetForeignKeyConstraintsAsyncGets the foreign key constraints.
GetForeignKeyConstraintNameOnColumnAsyncGets the foreign key constraint name on a column.
GetForeignKeyConstraintNamesAsyncGets the foreign key constraint names.
DropForeignKeyConstraintOnColumnIfExistsAsyncDrops a foreign key constraint on a column if it exists.
DropForeignKeyConstraintIfExistsAsyncDrops a foreign key constraint if it exists.

CreateForeignKeyConstraintIfNotExistsAsync

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

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
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.

csharp
Task&lt;DmForeignKeyConstraint?&gt; 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.

csharp
Task&lt;List&lt;DmForeignKeyConstraint&gt;&gt; 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.

csharp
Task&lt;string?&gt; 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&lt;string?&gt;

The foreign key constraint name if it exists, otherwise null.

GetForeignKeyConstraintNamesAsync

Gets the foreign key constraint names.

csharp
Task&lt;List&lt;string&gt;&gt; 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&lt;List&lt;string&gt;&gt;

A list of foreign key constraint names.

DropForeignKeyConstraintOnColumnIfExistsAsync

Drops a foreign key constraint on a column if it exists.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

True if the constraint was dropped, otherwise false.

DropForeignKeyConstraintIfExistsAsync

Drops a foreign key constraint if it exists.

csharp
Task&lt;bool&gt; 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&lt;bool&gt;

True if the constraint was dropped, otherwise false.