Table of Contents

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

connectionFactory IDbConnectionFactory

The 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

connectionFactory is 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

connectionFactory Func<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

connectionFactory is 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

connectionFactory IDbConnectionFactory<TConnection>

The connection factory to generate connections from.

Returns

IDbConnectionPool<TConnection>

An IDbConnectionPool<TConnection> that handles this factory.

Type Parameters

TConnection

The 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

connectionFactory is 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

connectionFactory Func<TConnection>

The function that creates a connection.

Returns

IDbConnectionPool<TConnection>

An IDbConnectionPool<TConnection> that handles this function.

Type Parameters

TConnection

The 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

connectionFactory is null.