Method Using
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
Using<T>(IDbConnectionFactory, Func<IDbConnection, T>)
Creates a connection from the factory, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static T Using<T>(this IDbConnectionFactory connectionFactory, Func<IDbConnection, T> action)
Parameters
connectionFactoryIDbConnectionFactoryThe connection factory to create the connection from.
actionFunc<IDbConnection, T>The action to execute. It receives the connection.
Returns
- T
The value returned by the action.
Type Parameters
TThe type returned from the action.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.
Using(IDbConnectionFactory, Action<IDbConnection>)
Creates a connection from the factory, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static void Using(this IDbConnectionFactory connectionFactory, Action<IDbConnection> action)
Parameters
connectionFactoryIDbConnectionFactoryThe connection factory to create the connection from.
actionAction<IDbConnection>The action to execute. It receives the connection.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.
Using<TConn, T>(IDbConnectionFactory<TConn>, Func<TConn, T>)
Creates a connection from the factory, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static T Using<TConn, T>(this IDbConnectionFactory<TConn> connectionFactory, Func<TConn, T> action) where TConn : IDbConnection
Parameters
connectionFactoryIDbConnectionFactory<TConn>The connection factory to create the connection from.
actionFunc<TConn, T>The action to execute. It receives the connection.
Returns
- T
The value returned by the action.
Type Parameters
TConnThe connection type.
TThe type returned from the action.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.
Using<TConn>(IDbConnectionFactory<TConn>, Action<TConn>)
Creates a connection from the factory, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static void Using<TConn>(this IDbConnectionFactory<TConn> connectionFactory, Action<TConn> action) where TConn : IDbConnection
Parameters
connectionFactoryIDbConnectionFactory<TConn>The connection factory to create the connection from.
actionAction<TConn>The action to execute. It receives the connection.
Type Parameters
TConnThe connection type.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.
Using<T>(IDbConnectionPool, Func<IDbConnection, T>)
Takes a connection from the pool, invokes the action, and then gives the connection back to the pool. The connection is not opened by this method.
public static T Using<T>(this IDbConnectionPool connectionPool, Func<IDbConnection, T> action)
Parameters
connectionPoolIDbConnectionPoolThe connection pool to take the connection from.
actionFunc<IDbConnection, T>The action to execute. It receives the connection.
Returns
- T
The value returned by the action.
Type Parameters
TThe type returned from the action.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been given back to the pool.
Exceptions
- ArgumentNullException
connectionPooloractionis null.
Using(IDbConnectionPool, Action<IDbConnection>)
Takes a connection from the pool, invokes the action, and then gives the connection back to the pool. The connection is not opened by this method.
public static void Using(this IDbConnectionPool connectionPool, Action<IDbConnection> action)
Parameters
connectionPoolIDbConnectionPoolThe connection pool to take the connection from.
actionAction<IDbConnection>The action to execute. It receives the connection.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been given back to the pool.
Exceptions
- ArgumentNullException
connectionPooloractionis null.
Using<TConn, T>(IDbConnectionPool<TConn>, Func<TConn, T>)
Takes a connection from the pool, invokes the action, and then gives the connection back to the pool. The connection is not opened by this method.
public static T Using<TConn, T>(this IDbConnectionPool<TConn> connectionPool, Func<TConn, T> action) where TConn : IDbConnection
Parameters
connectionPoolIDbConnectionPool<TConn>The connection pool to take the connection from.
actionFunc<TConn, T>The action to execute. It receives the connection.
Returns
- T
The value returned by the action.
Type Parameters
TConnThe connection type.
TThe type returned from the action.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been given back to the pool.
Exceptions
- ArgumentNullException
connectionPooloractionis null.
Using<TConn>(IDbConnectionPool<TConn>, Action<TConn>)
Takes a connection from the pool, invokes the action, and then gives the connection back to the pool. The connection is not opened by this method.
public static void Using<TConn>(this IDbConnectionPool<TConn> connectionPool, Action<TConn> action) where TConn : IDbConnection
Parameters
connectionPoolIDbConnectionPool<TConn>The connection pool to take the connection from.
actionAction<TConn>The action to execute. It receives the connection.
Type Parameters
TConnThe connection type.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been given back to the pool.
Exceptions
- ArgumentNullException
connectionPooloractionis null.
Using<TConn, T>(Func<TConn>, Func<TConn, T>)
Invokes the function to create a connection, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static T Using<TConn, T>(this Func<TConn> connectionFactory, Func<TConn, T> action) where TConn : IDbConnection
Parameters
connectionFactoryFunc<TConn>The function that creates the connection.
actionFunc<TConn, T>The action to execute. It receives the connection.
Returns
- T
The value returned by the action.
Type Parameters
TConnThe connection type.
TThe type returned from the action.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.
Using<TConn>(Func<TConn>, Action<TConn>)
Invokes the function to create a connection, invokes the action, and then disposes the connection. The connection is not opened by this method.
public static void Using<TConn>(this Func<TConn> connectionFactory, Action<TConn> action) where TConn : IDbConnection
Parameters
connectionFactoryFunc<TConn>The function that creates the connection.
actionAction<TConn>The action to execute. It receives the connection.
Type Parameters
TConnThe connection type.
Remarks
Useful for single-line operations. Exceptions thrown by the action propagate after the connection has been disposed.
Exceptions
- ArgumentNullException
connectionFactoryoractionis null.