Table of Contents

Method Using

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

Using(DbConnection)

Binds the query to a connection. The connection is opened late and closed again only if this call opened it; it is never disposed.

public BoundCall<NonQueryKind> Using(DbConnection connection)

Parameters

connection DbConnection

The connection to run on.

Returns

BoundCall<NonQueryKind>

The query, bound.

Exceptions

ArgumentNullException

connection is null.

Using(DbTransaction)

Binds the query to a transaction, which runs it on the transaction's connection.

public BoundCall<NonQueryKind> Using(DbTransaction transaction)

Parameters

transaction DbTransaction

The transaction to run in.

Returns

BoundCall<NonQueryKind>

The query, bound.

Remarks

The transaction must not be completed, and its connection must be open, when a terminal runs; otherwise the run throws InvalidOperationException. The query never opens, closes or gives back the transaction's connection.

Exceptions

ArgumentNullException

transaction is null.

Using<TConnection>(IDbConnectionPool<TConnection>)

Binds the query to a pool: each run takes a connection, opens it if needed, and gives it back.

public BoundCall<NonQueryKind> Using<TConnection>(IDbConnectionPool<TConnection> pool) where TConnection : DbConnection

Parameters

pool IDbConnectionPool<TConnection>

The pool to take connections from.

Returns

BoundCall<NonQueryKind>

The query, bound.

Type Parameters

TConnection

The type of the connection.

Remarks

The pool must hand out TConnection connections, which are DbConnections. A pool made by AsGeneric() is an IDbConnectionPool<IDbConnection> and does not fit; use a pool of DbConnection (or of a provider's connection type), or a factory.

Exceptions

ArgumentNullException

pool is null.

Using<TConnection>(IDbConnectionFactory<TConnection>)

Binds the query to a factory: each run creates a connection, opens it, and disposes it when finished.

public BoundCall<NonQueryKind> Using<TConnection>(IDbConnectionFactory<TConnection> factory) where TConnection : DbConnection

Parameters

factory IDbConnectionFactory<TConnection>

The factory that creates connections.

Returns

BoundCall<NonQueryKind>

The query, bound.

Type Parameters

TConnection

The type of the connection.

Exceptions

ArgumentNullException

factory is null.