Class ConnectionHelper
Helper class for opening database connection. It ensures opening and closing of the connection.
Namespace: Kros.Data
Assembly: Kros.Utils.dll
Syntax
public class ConnectionHelper : Suspender
Methods
OpenConnection(IDbConnection)
If database connection
is closed, it is opened immediately. After disposing of returned
object, the connection is closed, but only if it was opened. So when already opened connection is passed
in the parameter, nothing is done with it.
Declaration
public static IDisposable OpenConnection(IDbConnection connection)
Parameters
Type | Name | Description |
---|---|---|
System.Data.IDbConnection | connection | Database connection. |
Returns
Type | Description |
---|---|
System.IDisposable | Helper object, which closes connection when it is disposed of. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Value of |
ResumeCore()
Declaration
protected override void ResumeCore()
Overrides
SuspendCore()
Declaration
protected override void SuspendCore()