Table of Contents

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

connection DbConnection

The connection to transact with.

configureAwait bool

If true (default) will retain the context after opening.

cancellationToken CancellationToken

An 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

connection DbConnection

The connection to transact with.

cancellationToken CancellationToken

An 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

connection IDbConnection

The connection to transact with.

configureAwait bool

If true (default) will retain the context after opening.

cancellationToken CancellationToken

An 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

connection IDbConnection

The connection to transact with.

cancellationToken CancellationToken

An cancellation token to cancel opening.

Returns

ValueTask<ConnectionState>

A task containing the prior connection state.