Class DbConnectionPlusConfiguration
- Namespace
- RentADeveloper.DbConnectionPlus.Configuration
- Assembly
- RentADeveloper.DbConnectionPlus.dll
The configuration for DbConnectionPlus.
public sealed class DbConnectionPlusConfiguration : IFreezable
- Inheritance
-
DbConnectionPlusConfiguration
- Implements
- Inherited Members
- Extension Methods
Properties
EnumSerializationMode
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.
public EnumSerializationMode EnumSerializationMode { get; set; }
Property Value
Exceptions
- 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.
public static DbConnectionPlusConfiguration Instance { get; }
Property Value
InterceptDbCommand
A function that can be used to intercept database commands executed via DbConnectionPlus. Can be used for logging or modifying commands before execution.
public InterceptDbCommand? InterceptDbCommand { get; set; }
Property Value
Exceptions
- InvalidOperationException
An attempt was made to modify this property and the configuration of DbConnectionPlus is already frozen and can no longer be modified.
Methods
Entity<TEntity>()
Gets a builder for configuring the entity type TEntity.
public EntityTypeBuilder<TEntity> Entity<TEntity>()
Returns
- EntityTypeBuilder<TEntity>
A builder to configure the entity type.
Type Parameters
TEntityThe type of the entity to configure.
Exceptions
- 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.
public void RegisterDatabaseAdapter<TConnection>(IDatabaseAdapter adapter) where TConnection : DbConnection
Parameters
adapterIDatabaseAdapterThe database adapter to associate with the connection type
TConnection.
Type Parameters
TConnectionThe type of database connection for which
adapteris being registered.
Exceptions
- ArgumentNullException
adapteris null.