Table of Contents

Method EnsureOpen

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

EnsureOpen(IDbConnection)

Opens the connection if it is not open (a broken connection is closed first) and returns the prior state, so you can close it afterwards if it was not open.

public static ConnectionState EnsureOpen(this IDbConnection connection)

Parameters

connection IDbConnection

The connection to open.

Returns

ConnectionState

The state the connection was in before this call.

Remarks

A connection that is already open is left as it is, whatever it is doing. Nothing here closes it afterwards; use EnsureOpenScope<TConnection>(TConnection) for a scope that does.

Exceptions

ArgumentNullException

connection is null.