Method AsPool
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
AsPool(IDbConnectionFactory)
Presents a connection factory as a connection pool that creates a new connection when one is taken and disposes it when it is given back.
public static IDbConnectionPool AsPool(this IDbConnectionFactory connectionFactory)
Parameters
connectionFactoryIDbConnectionFactoryThe connection factory to generate connections from.
Returns
- IDbConnectionPool
An IDbConnectionPool that handles this factory.
Remarks
This is the "get in, get out" model: every command execution creates its own connection, opens it only if needed, and disposes it when the command is finished.
Exceptions
- ArgumentNullException
connectionFactoryis null.
AsPool(Func<IDbConnection>)
Presents a connection factory function as a connection pool that invokes the function when a connection is taken and disposes the connection when it is given back.
public static IDbConnectionPool AsPool(this Func<IDbConnection> connectionFactory)
Parameters
connectionFactoryFunc<IDbConnection>The function that creates a connection.
Returns
- IDbConnectionPool
An IDbConnectionPool that handles this function.
Remarks
This is the "get in, get out" model: every command execution creates its own connection, opens it only if needed, and disposes it when the command is finished.
Exceptions
- ArgumentNullException
connectionFactoryis null.
AsPool<TConnection>(IDbConnectionFactory<TConnection>)
Presents a typed connection factory as a connection pool that creates a new connection when one is taken and disposes it when it is given back.
public static IDbConnectionPool<TConnection> AsPool<TConnection>(this IDbConnectionFactory<TConnection> connectionFactory) where TConnection : IDbConnection
Parameters
connectionFactoryIDbConnectionFactory<TConnection>The connection factory to generate connections from.
Returns
- IDbConnectionPool<TConnection>
An IDbConnectionPool<TConnection> that handles this factory.
Type Parameters
TConnectionThe connection type.
Remarks
This is the "get in, get out" model: every command execution creates its own connection, opens it only if needed, and disposes it when the command is finished.
Exceptions
- ArgumentNullException
connectionFactoryis null.
AsPool<TConnection>(Func<TConnection>)
Presents a typed connection factory function as a connection pool that invokes the function when a connection is taken and disposes the connection when it is given back.
public static IDbConnectionPool<TConnection> AsPool<TConnection>(this Func<TConnection> connectionFactory) where TConnection : IDbConnection
Parameters
connectionFactoryFunc<TConnection>The function that creates a connection.
Returns
- IDbConnectionPool<TConnection>
An IDbConnectionPool<TConnection> that handles this function.
Type Parameters
TConnectionThe connection type.
Remarks
This is the "get in, get out" model: every command execution creates its own connection, opens it only if needed, and disposes it when the command is finished.
Exceptions
- ArgumentNullException
connectionFactoryis null.