Class DbConnectionPlusConfiguration
The configuration for DbConnectionPlus.
Implements
Inherited Members
Namespace: RentADeveloper.DbConnectionPlus.Configuration
Assembly: RentADeveloper.DbConnectionPlus.dll
Syntax
public sealed class DbConnectionPlusConfiguration : IFreezable
Properties
View SourceEnumSerializationMode
Controls how Enum values are serialized when they are sent to a database using one of the following methods:
1. When an entity containing an enum property is inserted via InsertEntities<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken), InsertEntitiesAsync<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken), InsertEntity<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken) or InsertEntityAsync<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken).
2. When an entity containing an enum property is updated via UpdateEntities<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken), UpdateEntitiesAsync<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken), UpdateEntity<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken) or UpdateEntityAsync<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken).
3. When an enum value is passed as a parameter to an SQL statement via Parameter(object?, string?).
4. When a sequence of enum values is passed as a temporary table to an SQL statement via TemporaryTable<T>(IEnumerable<T>, string?).
5. When objects containing an enum property are passed as a temporary table to an SQL statement via TemporaryTable<T>(IEnumerable<T>, string?).
The default is Strings.
Declaration
public EnumSerializationMode EnumSerializationMode { get; set; }
Property Value
| Type | Description |
|---|---|
| EnumSerializationMode |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | An attempt was made to modify this property and the configuration of DbConnectionPlus is already frozen and can no longer be modified. |
Instance
The singleton instance of DbConnectionPlusConfiguration.
Declaration
public static DbConnectionPlusConfiguration Instance { get; }
Property Value
| Type | Description |
|---|---|
| DbConnectionPlusConfiguration |
InterceptDbCommand
A function that can be used to intercept database commands executed via DbConnectionPlus. Can be used for logging or modifying commands before execution.
Declaration
public InterceptDbCommand? InterceptDbCommand { get; set; }
Property Value
| Type | Description |
|---|---|
| InterceptDbCommand |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | An attempt was made to modify this property and the configuration of DbConnectionPlus is already frozen and can no longer be modified. |
Methods
View SourceEntity<TEntity>()
Gets a builder for configuring the entity type TEntity.
Declaration
public EntityTypeBuilder<TEntity> Entity<TEntity>()
Returns
| Type | Description |
|---|---|
| EntityTypeBuilder<TEntity> | A builder to configure the entity type. |
Type Parameters
| Name | Description |
|---|---|
| TEntity | The type of the entity to configure. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The configuration of DbConnectionPlus is already frozen and can no longer be modified. |
RegisterDatabaseAdapter<TConnection>(IDatabaseAdapter)
Registers a database adapter for the connection type TConnection.
If an adapter is already registered for the connection type TConnection, the existing
adapter is replaced.
Declaration
public void RegisterDatabaseAdapter<TConnection>(IDatabaseAdapter adapter) where TConnection : DbConnection
Parameters
| Type | Name | Description |
|---|---|---|
| IDatabaseAdapter | adapter | The database adapter to associate with the connection type |
Type Parameters
| Name | Description |
|---|---|
| TConnection | The type of database connection for which |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|