IDatabaseTableMethods ​
Namespace: MJCZone.DapperMatic.Interfaces
Assembly: MJCZone.DapperMatic
Summary ​
Provides database table 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 (10)
Methods ​
Method | Summary |
---|---|
DoesTableExistAsync | Checks if a table exists in the database. |
CreateTablesIfNotExistsAsync | Creates tables if they do not exist. |
CreateTableIfNotExistsAsync | Creates a table if it does not exist. |
CreateTableIfNotExistsAsync | Creates a table with specified columns and constraints if it does not exist. |
GetTableAsync | Retrieves a table definition from the database. |
GetTablesAsync | Retrieves a list of table definitions from the database. |
GetTableNamesAsync | Retrieves a list of table names from the database. |
DropTableIfExistsAsync | Drops a table if it exists in the database. |
RenameTableIfExistsAsync | Renames a table if it exists in the database. |
TruncateTableIfExistsAsync | Truncates a table if it exists in the database. |
DoesTableExistAsync ​
Checks if a table exists in the database.
Task<bool> DoesTableExistAsync(IDbConnection db, string schemaName, string tableName, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- 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 whether the table exists.
CreateTablesIfNotExistsAsync ​
Creates tables if they do not exist.
Task CreateTablesIfNotExistsAsync(IDbConnection db, DmTable[] tables, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- tables (DmTable[]) - The table definitions.
- tx (IDbTransaction) - The database transaction.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task
A task that represents the asynchronous operation.
CreateTableIfNotExistsAsync ​
Creates a table if it does not exist.
Task<bool> CreateTableIfNotExistsAsync(IDbConnection db, DmTable table, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- table (DmTable) - The table definition.
- 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 whether the table was created.
CreateTableIfNotExistsAsync ​
Creates a table with specified columns and constraints if it does not exist.
Task<bool> CreateTableIfNotExistsAsync(IDbConnection db, string schemaName, string tableName, DmColumn[] columns, DmPrimaryKeyConstraint primaryKey, DmCheckConstraint[] checkConstraints, DmDefaultConstraint[] defaultConstraints, DmUniqueConstraint[] uniqueConstraints, DmForeignKeyConstraint[] foreignKeyConstraints, DmIndex[] indexes, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- columns (DmColumn[]) - The columns of the table.
- primaryKey (DmPrimaryKeyConstraint) - The primary key constraint.
- checkConstraints (DmCheckConstraint[]) - The check constraints.
- defaultConstraints (DmDefaultConstraint[]) - The default constraints.
- uniqueConstraints (DmUniqueConstraint[]) - The unique constraints.
- foreignKeyConstraints (DmForeignKeyConstraint[]) - The foreign key constraints.
- indexes (DmIndex[]) - The indexes.
- 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 whether the table was created.
GetTableAsync ​
Retrieves a table definition from the database.
Task<DmTable?> GetTableAsync(IDbConnection db, string schemaName, string tableName, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- tx (IDbTransaction) - The database transaction.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<DmTable?>
A task that represents the asynchronous operation. The task result contains the table definition.
GetTablesAsync ​
Retrieves a list of table definitions from the database.
Task<List<DmTable>> GetTablesAsync(IDbConnection db, string schemaName, string tableNameFilter, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the tables.
- tableNameFilter (string) - The table name filter.
- tx (IDbTransaction) - The database transaction.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<List<DmTable>>
A task that represents the asynchronous operation. The task result contains a list of table definitions.
GetTableNamesAsync ​
Retrieves a list of table names from the database.
Task<List<string>> GetTableNamesAsync(IDbConnection db, string schemaName, string tableNameFilter, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the tables.
- tableNameFilter (string) - The table name filter.
- tx (IDbTransaction) - The database transaction.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<List<string>>
A task that represents the asynchronous operation. The task result contains a list of table names.
DropTableIfExistsAsync ​
Drops a table if it exists in the database.
Task<bool> DropTableIfExistsAsync(IDbConnection db, string schemaName, string tableName, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- 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 whether the table was dropped.
RenameTableIfExistsAsync ​
Renames a table if it exists in the database.
Task<bool> RenameTableIfExistsAsync(IDbConnection db, string schemaName, string tableName, string newTableName, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- newTableName (string) - The new name of the table.
- 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 whether the table was renamed.
TruncateTableIfExistsAsync ​
Truncates a table if it exists in the database.
Task<bool> TruncateTableIfExistsAsync(IDbConnection db, string schemaName, string tableName, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name of the table.
- tableName (string) - The name of the table.
- 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 whether the table was truncated.