Show / Hide Table of Contents

    Class ConnectionHelper

    Helper class for opening database connection. It ensures opening and closing of the connection.

    Inheritance
    System.Object
    Suspender
    ConnectionHelper
    Inherited Members
    Suspender.Suspend()
    Suspender.IsSuspended
    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 connection is null.

    ResumeCore()

    Declaration
    protected override void ResumeCore()
    Overrides
    Suspender.ResumeCore()

    SuspendCore()

    Declaration
    protected override void SuspendCore()
    Overrides
    Suspender.SuspendCore()
    Back to top KROS a.s.