Method EnsureOpenAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
EnsureOpenAsync(DbConnection, bool, CancellationToken)
If the connection isn't open, opens the connection.
If the connection is in neither open or close, first closes the connection, then opens it.
public static ValueTask<ConnectionState> EnsureOpenAsync(this DbConnection connection, bool configureAwait = true, CancellationToken cancellationToken = default)
Parameters
connectionDbConnectionThe connection to transact with.
configureAwaitboolIf true (default) will retain the context after opening.
cancellationTokenCancellationTokenAn cancellation token to cancel opening.
Returns
- ValueTask<ConnectionState>
A task containing the prior connection state.
EnsureOpenAsync(DbConnection, CancellationToken)
If the connection isn't open, opens the connection.
If the connection is in neither open or close, first closes the connection, then opens it.
public static ValueTask<ConnectionState> EnsureOpenAsync(this DbConnection connection, CancellationToken cancellationToken)
Parameters
connectionDbConnectionThe connection to transact with.
cancellationTokenCancellationTokenAn cancellation token to cancel opening.
Returns
- ValueTask<ConnectionState>
A task containing the prior connection state.
EnsureOpenAsync(IDbConnection, bool, CancellationToken)
If the connection isn't open, opens the connection.
If the connection is in neither open or close, first closes the connection, then opens it.
public static ValueTask<ConnectionState> EnsureOpenAsync(this IDbConnection connection, bool configureAwait = true, CancellationToken cancellationToken = default)
Parameters
connectionIDbConnectionThe connection to transact with.
configureAwaitboolIf true (default) will retain the context after opening.
cancellationTokenCancellationTokenAn cancellation token to cancel opening.
Returns
- ValueTask<ConnectionState>
A task containing the prior connection state.
EnsureOpenAsync(IDbConnection, CancellationToken)
If the connection isn't open, opens the connection.
If the connection is in neither open or close, first closes the connection, then opens it.
public static ValueTask<ConnectionState> EnsureOpenAsync(this IDbConnection connection, CancellationToken cancellationToken)
Parameters
connectionIDbConnectionThe connection to transact with.
cancellationTokenCancellationTokenAn cancellation token to cancel opening.
Returns
- ValueTask<ConnectionState>
A task containing the prior connection state.