Skip to content

IDatabaseIndexMethods ​

Namespace: MJCZone.DapperMatic.Interfaces

Assembly: MJCZone.DapperMatic

Summary ​

Provides database index 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 (12)

Methods ​

MethodSummary
CreateIndexIfNotExistsAsyncCreates an index if it does not already exist.
CreateIndexIfNotExistsAsyncCreates an index if it does not already exist.
DoesIndexExistOnColumnAsyncChecks if an index exists on a specific column.
DoesIndexExistAsyncChecks if an index exists.
GetIndexesOnColumnAsyncGets the indexes on a specific column.
GetIndexAsyncGets a specific index.
GetIndexesAsyncGets the indexes.
GetIndexNamesOnColumnAsyncGets the index names on a specific column.
GetIndexNamesAsyncGets the index names.
DropIndexesOnColumnIfExistsAsyncDrops the indexes on a specific column if they exist.
DropIndexIfExistsAsyncDrops an index if it exists.
RenameIndexIfExistsAsyncRenames an index if it exists.

CreateIndexIfNotExistsAsync ​

Creates an index if it does not already exist.

csharp
Task<bool> CreateIndexIfNotExistsAsync(
    IDbConnection db,
    DmIndex index,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • index (DmIndex) - The index.
  • 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 success.

CreateIndexIfNotExistsAsync ​

Creates an index if it does not already exist.

csharp
Task<bool> CreateIndexIfNotExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexName,
    DmOrderedColumn[] columns,
    bool isUnique,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • indexName (string) - The index name.
  • columns (DmOrderedColumn[]) - The columns to be indexed.
  • isUnique (bool) - Indicates whether the index is unique.
  • 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 success.

DoesIndexExistOnColumnAsync ​

Checks if an index exists on a specific column.

csharp
Task<bool> DoesIndexExistOnColumnAsync(
    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>

A task that represents the asynchronous operation. The task result contains a boolean indicating existence.

DoesIndexExistAsync ​

Checks if an index exists.

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

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • indexName (string) - The index 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 existence.

GetIndexesOnColumnAsync ​

Gets the indexes on a specific column.

csharp
Task<List<DmIndex>> GetIndexesOnColumnAsync(
    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<List<DmIndex>>

A task that represents the asynchronous operation. The task result contains a list of indexes.

GetIndexAsync ​

Gets a specific index.

csharp
Task&lt;DmIndex?&gt; GetIndexAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

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

Returns ​

Type: Task<DmIndex?>

A task that represents the asynchronous operation. The task result contains the index.

GetIndexesAsync ​

Gets the indexes.

csharp
Task&lt;List&lt;DmIndex&gt;&gt; GetIndexesAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexNameFilter,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

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

Returns ​

Type: Task<List<DmIndex>>

A task that represents the asynchronous operation. The task result contains a list of indexes.

GetIndexNamesOnColumnAsync ​

Gets the index names on a specific column.

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

A task that represents the asynchronous operation. The task result contains a list of index names.

GetIndexNamesAsync ​

Gets the index names.

csharp
Task&lt;List&lt;string&gt;&gt; GetIndexNamesAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexNameFilter,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

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

Returns ​

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

A task that represents the asynchronous operation. The task result contains a list of index names.

DropIndexesOnColumnIfExistsAsync ​

Drops the indexes on a specific column if they exist.

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

A task that represents the asynchronous operation. The task result contains a boolean indicating success.

DropIndexIfExistsAsync ​

Drops an index if it exists.

csharp
Task&lt;bool&gt; DropIndexIfExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

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

Returns ​

Type: Task&lt;bool&gt;

A task that represents the asynchronous operation. The task result contains a boolean indicating success.

RenameIndexIfExistsAsync ​

Renames an index if it exists.

csharp
Task&lt;bool&gt; RenameIndexIfExistsAsync(
    IDbConnection db,
    string schemaName,
    string tableName,
    string indexName,
    string newIndexName,
    IDbTransaction tx,
    CancellationToken cancellationToken)

Parameters ​

  • db (IDbConnection) - The database connection.
  • schemaName (string) - The schema name.
  • tableName (string) - The table name.
  • indexName (string) - The current name.
  • newIndexName (string) - The new name.
  • tx (IDbTransaction) - The transaction to use, or null.
  • cancellationToken (CancellationToken) - The cancellation token.

Returns ​

Type: Task&lt;bool&gt;

True if it was renamed; false if it does not exist, or the new name is already taken.