IDatabaseColumnMethods ​
Namespace: MJCZone.DapperMatic.Interfaces
Assembly: MJCZone.DapperMatic
Summary ​
Provides database column 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 (8)
Methods ​
Method | Summary |
---|---|
CreateColumnIfNotExistsAsync | Creates a column if it does not exist. |
CreateColumnIfNotExistsAsync | Creates a column if it does not exist. |
DoesColumnExistAsync | Checks if a column exists. |
GetColumnAsync | Gets a column definition. |
GetColumnsAsync | Gets a list of column definitions. |
GetColumnNamesAsync | Gets a list of column names. |
DropColumnIfExistsAsync | Drops a column if it exists. |
RenameColumnIfExistsAsync | Renames a column if it exists. |
CreateColumnIfNotExistsAsync ​
Creates a column if it does not exist.
Task<bool> CreateColumnIfNotExistsAsync(IDbConnection db, DmColumn column, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- column (DmColumn) - The column definition.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<bool>
True if the column was created, false otherwise.
CreateColumnIfNotExistsAsync ​
Creates a column if it does not exist.
Task<bool> CreateColumnIfNotExistsAsync(IDbConnection db, string schemaName, string tableName, string columnName, Type dotnetType, string providerDataType, Int32} length, Int32} precision, Int32} scale, string checkExpression, string defaultExpression, bool isNullable, bool isPrimaryKey, bool isAutoIncrement, bool isUnique, bool isUnicode, bool isIndexed, bool isForeignKey, string referencedTableName, string referencedColumnName, DmForeignKeyAction} onDelete, DmForeignKeyAction} onUpdate, 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.
- dotnetType (Type) - The .NET type of the column.
- providerDataType (string) - The provider-specific data type.
- length (Int32}) - The length of the column.
- precision (Int32}) - The precision of the column.
- scale (Int32}) - The scale of the column.
- checkExpression (string) - The check expression for the column.
- defaultExpression (string) - The default expression for the column.
- isNullable (bool) - Whether the column is nullable.
- isPrimaryKey (bool) - Whether the column is a primary key.
- isAutoIncrement (bool) - Whether the column is auto-incremented.
- isUnique (bool) - Whether the column is unique.
- isUnicode (bool) - Whether the column supports unicode characters.
- isIndexed (bool) - Whether the column is indexed.
- isForeignKey (bool) - Whether the column is a foreign key.
- referencedTableName (string) - The referenced table name for the foreign key.
- referencedColumnName (string) - The referenced column name for the foreign key.
- onDelete (DmForeignKeyAction}) - The action to take on delete.
- onUpdate (DmForeignKeyAction}) - The action to take on update.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<bool>
True if the column was created, false otherwise.
DoesColumnExistAsync ​
Checks if a column exists.
Task<bool> DoesColumnExistAsync(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 column exists, false otherwise.
GetColumnAsync ​
Gets a column definition.
Task<DmColumn?> GetColumnAsync(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<DmColumn?>
The column definition, or null if the column does not exist.
GetColumnsAsync ​
Gets a list of column definitions.
Task<List<DmColumn>> GetColumnsAsync(IDbConnection db, string schemaName, string tableName, string columnNameFilter, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name.
- tableName (string) - The table name.
- columnNameFilter (string) - The column name filter.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<List<DmColumn>>
A list of column definitions.
GetColumnNamesAsync ​
Gets a list of column names.
Task<List<string>> GetColumnNamesAsync(IDbConnection db, string schemaName, string tableName, string columnNameFilter, IDbTransaction tx, CancellationToken cancellationToken)
Parameters ​
- db (IDbConnection) - The database connection.
- schemaName (string) - The schema name.
- tableName (string) - The table name.
- columnNameFilter (string) - The column name filter.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<List<string>>
A list of column names.
DropColumnIfExistsAsync ​
Drops a column if it exists.
Task<bool> DropColumnIfExistsAsync(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 column was dropped, false otherwise.
RenameColumnIfExistsAsync ​
Renames a column if it exists.
Task<bool> RenameColumnIfExistsAsync(IDbConnection db, string schemaName, string tableName, string columnName, string newColumnName, 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.
- newColumnName (string) - The new column name.
- tx (IDbTransaction) - The transaction to use, or null.
- cancellationToken (CancellationToken) - The cancellation token.
Returns ​
Type: Task<bool>
True if the column was renamed, false otherwise.