Search Results for

    Show / Hide Table of Contents

    Class AdbKeepOpenConnectionBuilder

    An Adb connection builder that creates one AdbKeepOpenConnection instance, as well as AdbCommandBuilder instances referencing the connection builder and the AdbKeepOpenConnection it creates.

    The Adb connection builder instance is created via factory methods on AdbProvider and AdbConnectionString.

    The key feature of "KeepOpen" connections is that they keep the underlying .NET DbConnection open even after a worker calls Close() and Dispose(). This allows using a single transaction or specific temporary table(s) across multiple workers, which can be very useful. When this functionality is not needed, a standard AdbConnectionBuilder should be used instead.

    Note: This builder (unlike AdbConnectionBuilder) must be disposed after use - it is only then that the underlying .NET connection will be closed and disposed.

    Inheritance
    Object
    AdbConnectionBuilderBase
    AdbKeepOpenConnectionBuilder
    Implements
    IAdbConnectionBuilder
    IDisposable
    Inherited Members
    AdbConnectionBuilderBase.ConnectionMode
    AdbConnectionBuilderBase.ConnectionString
    AdbConnectionBuilderBase.CreateCommandBuilder(String, CommandType)
    AdbConnectionBuilderBase.CreateCommandBuilder(String)
    AdbConnectionBuilderBase.CreateCommandBuilder()
    AdbConnectionBuilderBase.Provider
    AdbConnectionBuilderBase.ToString()
    Namespace: actionETL.Adb
    Assembly: actionETL.dll
    Syntax
    public sealed class AdbKeepOpenConnectionBuilder : AdbConnectionBuilderBase, IAdbConnectionBuilder, IDisposable
    Remarks

    Do design database workers to take AdbConnectionString, IAdbConnectionBuilder, and AdbCommandBuilder instances as parameters, which allows them to support connections with different AdbConnectionMode. Conversely, avoid passing AdbConnection, AdbKeepOpenConnection, AdbCommand, or connection (text) strings to workers.

    Examples

    Adb Keep Open Connection has examples of how to use this class.

    Methods

    Create()

    Creates an Adb "KeepOpen" database connection, using the connection details of the AdbKeepOpenConnectionBuilder instance.

    Note: The AdbConnection instance is not thread-safe, and must only be used in a single place (in a single worker) at any one time.

    The connection can be opened and closed multiple times as needed, and it must be disposed after use. Disposal should almost always be done by whoever created the connection, typically via DisposeOnFinished<TDisposable>(TDisposable) or UsingActionWorker<TDisposable> if used across multiple method calls, or by a using statement if created and disposed in a single method and thread, without being passed to any other workers. See Disposing Disposables for details.

    Note however that closing and disposing the "KeepOpen" connection does not actually close or dispose the underlying .NET connection. This only happens when this connection builder instance that created the connection is disposed.

    Declaration
    public override IAdbConnection Create()
    Returns
    Type Description
    IAdbConnection

    The AdbKeepOpenConnection connection, typed as the interface IAdbConnection.

    Overrides
    AdbConnectionBuilderBase.Create()
    Exceptions
    Type Condition
    ArgumentException

    Bad ConnectionString format.

    Exception

    See the provider documentation for which specific exceptions Open() can throw, it typically includes DbException and InvalidOperationException.

    ObjectDisposedException

    AdbKeepOpenConnection: Cannot call Create() after disposing the object.

    Dispose()

    Disposes the keep open connection builder, which also closes and disposes its connection, and rolls back any active transaction.

    Declaration
    public void Dispose()

    Implements

    IAdbConnectionBuilder
    System.IDisposable

    See Also

    IAdbConnectionBuilder
    AdbKeepOpenConnection
    IAdbConnection
    AdbProvider
    AdbConnectionString
    AdbCommand
    In This Article
    Back to top Copyright © 2023 Envobi Ltd