Class DbConnectionExtensions
Provides extension methods for IDbConnection to enhance connection management and request execution.
public static class DbConnectionExtensions
- Inheritance
-
DbConnectionExtensions
- Inherited Members
Methods
Ready(IDbConnection)
Ensures the database connection is in a usable state, reopening it if necessary.
public static IDbConnection Ready(this IDbConnection connection)
Parameters
connectionIDbConnectionThe database connection to check and prepare.
Returns
- IDbConnection
The prepared IDbConnection instance.
Exceptions
- ArgumentOutOfRangeException
Thrown if the connection state is invalid or unrecognized.
- InvalidOperationException
ResolveAsync<TModel>(IDbConnection, IDataRequest<IDbConnection, TModel>)
Executes a data request asynchronously on the specified database connection.
public static Task<TModel> ResolveAsync<TModel>(this IDbConnection connection, IDataRequest<IDbConnection, TModel> dataRequest)
Parameters
connectionIDbConnectionThe database connection to use for the request.
dataRequestIDataRequest<IDbConnection, TModel>The request to execute, including the command and resolver.
Returns
- Task<TModel>
The result of the request execution as an instance of
TModel.
Type Parameters
TModelThe type of the result model.
Remarks
This is the execute path over an IDb connection. An ApiException raised by the resolver — including a ConcurrencyException signalling an optimistic-concurrency conflict — surfaces to the caller unchanged, preserving its type and metadata so the caller can react to the conflict (for example, reload and retry). Resolver cancellation also propagates unchanged, retaining its cancellation token and canceled task status. Other infrastructure faults, including timeouts, are wrapped as an OperationFailedException. An infrastructure exception containing a cancellation exception is still a fault; this method does not unwrap its cause.
Exceptions
- ConcurrencyException
Propagated unchanged when the resolver reports an optimistic-concurrency conflict.
- OperationCanceledException
Propagated unchanged when the resolver reports cancellation.
- OperationFailedException
Thrown when a non-application (infrastructure) error occurs while executing the request.