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 DbQueryUsing Using(DbConnection connection)

Parameters

connection DbConnection

The connection to run on.

Returns

DbQueryUsing

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 DbQueryUsing Using(DbTransaction transaction)

Parameters

transaction DbTransaction

The transaction to run in.

Returns

DbQueryUsing

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 DbQueryUsing Using<TConnection>(IDbConnectionPool<TConnection> pool) where TConnection : DbConnection

Parameters

pool IDbConnectionPool<TConnection>

The pool to take connections from.

Returns

DbQueryUsing

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 DbQueryUsing Using<TConnection>(IDbConnectionFactory<TConnection> factory) where TConnection : DbConnection

Parameters

factory IDbConnectionFactory<TConnection>

The factory that creates connections.

Returns

DbQueryUsing

The query, bound.

Type Parameters

TConnection

The type of the connection.

Exceptions

ArgumentNullException

factory is null.