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 BoundParams<ScalarKind<T>, TParams> Using(DbConnection connection)
Parameters
connectionDbConnectionThe connection to run on.
Returns
- BoundParams<ScalarKind<T>, TParams>
The query, bound.
Exceptions
- ArgumentNullException
connectionis null.
Using(DbTransaction)
Binds the query to a transaction, which runs it on the transaction's connection.
public BoundParams<ScalarKind<T>, TParams> Using(DbTransaction transaction)
Parameters
transactionDbTransactionThe transaction to run in.
Returns
- BoundParams<ScalarKind<T>, TParams>
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
transactionis 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 BoundParams<ScalarKind<T>, TParams> Using<TConnection>(IDbConnectionPool<TConnection> pool) where TConnection : DbConnection
Parameters
poolIDbConnectionPool<TConnection>The pool to take connections from.
Returns
- BoundParams<ScalarKind<T>, TParams>
The query, bound.
Type Parameters
TConnectionThe 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
poolis null.
Using<TConnection>(IDbConnectionFactory<TConnection>)
Binds the query to a factory: each run creates a connection, opens it, and disposes it when finished.
public BoundParams<ScalarKind<T>, TParams> Using<TConnection>(IDbConnectionFactory<TConnection> factory) where TConnection : DbConnection
Parameters
factoryIDbConnectionFactory<TConnection>The factory that creates connections.
Returns
- BoundParams<ScalarKind<T>, TParams>
The query, bound.
Type Parameters
TConnectionThe type of the connection.
Exceptions
- ArgumentNullException
factoryis null.