Skip to content

IDatabaseDefaultConstraintMethods

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
CreateDefaultConstraintIfNotExistsAsyncCreates a default constraint if it does not already exist.
CreateDefaultConstraintIfNotExistsAsyncCreates a default constraint if it does not already exist.
DoesDefaultConstraintExistOnColumnAsyncChecks if a default constraint exists on a column.
DoesDefaultConstraintExistAsyncChecks if a default constraint exists.
GetDefaultConstraintOnColumnAsyncGets the default constraint on a column.
GetDefaultConstraintAsyncGets a default constraint.
GetDefaultConstraintsAsyncGets a list of default constraints.
GetDefaultConstraintNameOnColumnAsyncGets the name of the default constraint on a column.
GetDefaultConstraintNamesAsyncGets a list of default constraint names.
DropDefaultConstraintOnColumnIfExistsAsyncDrops the default constraint on a column if it exists.
DropDefaultConstraintIfExistsAsyncDrops a default constraint if it exists.

CreateDefaultConstraintIfNotExistsAsync

Creates a default constraint if it does not already exist.

csharp
Task<bool> CreateDefaultConstraintIfNotExistsAsync(
    IDbConnection db,
    DmDefaultConstraint constraint,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters

  • db (IDbConnection) - The database connection.
  • constraint (DmDefaultConstraint) - The default constraint to create.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint was created, false otherwise.

CreateDefaultConstraintIfNotExistsAsync

Creates a default constraint if it does not already exist.

csharp
Task<bool> CreateDefaultConstraintIfNotExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string columnName,
    string constraintName,
    string expression,
    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.
  • constraintName (string) - The constraint name.
  • expression (string) - The constraint expression.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint was created, false otherwise.

DoesDefaultConstraintExistOnColumnAsync

Checks if a default constraint exists on a column.

csharp
Task<bool> DoesDefaultConstraintExistOnColumnAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint exists, false otherwise.

DoesDefaultConstraintExistAsync

Checks if a default constraint exists.

csharp
Task<bool> DoesDefaultConstraintExistAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<bool>

True if the constraint exists, false otherwise.

GetDefaultConstraintOnColumnAsync

Gets the default constraint on a column.

csharp
Task<DmDefaultConstraint?> GetDefaultConstraintOnColumnAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<DmDefaultConstraint?>

The default constraint, or null if it does not exist.

GetDefaultConstraintAsync

Gets a default constraint.

csharp
Task&lt;DmDefaultConstraint?&gt; GetDefaultConstraintAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<DmDefaultConstraint?>

The default constraint, or null if it does not exist.

GetDefaultConstraintsAsync

Gets a list of default constraints.

csharp
Task&lt;List&lt;DmDefaultConstraint&gt;&gt; GetDefaultConstraintsAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task<List<DmDefaultConstraint>>

A list of default constraints.

GetDefaultConstraintNameOnColumnAsync

Gets the name of the default constraint on a column.

csharp
Task&lt;string?&gt; GetDefaultConstraintNameOnColumnAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;string?&gt;

The name of the default constraint, or null if it does not exist.

GetDefaultConstraintNamesAsync

Gets a list of default constraint names.

csharp
Task&lt;List&lt;string&gt;&gt; GetDefaultConstraintNamesAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

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

A list of default constraint names.

DropDefaultConstraintOnColumnIfExistsAsync

Drops the default constraint on a column if it exists.

csharp
Task&lt;bool&gt; DropDefaultConstraintOnColumnIfExistsAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;bool&gt;

True if the constraint was dropped, false otherwise.

DropDefaultConstraintIfExistsAsync

Drops a default constraint if it exists.

csharp
Task&lt;bool&gt; DropDefaultConstraintIfExistsAsync(
    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 transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns

Type: Task&lt;bool&gt;

True if the constraint was dropped, false otherwise.