Class AdbConnectionString
A class that contains a read-only connection string plus its provider.
The AdbConnectionString instance can create AdbConnectionBuilder,
AdbKeepOpenConnectionBuilder, and AdbCommandBuilder instances.
Use an AdbConnectionString instance when you (or a worker) need to create
multiple connection and command builders, all using the same provider and connection string.
When only needing a single connection or command builder, use the factory methods on
AdbProvider instead.
Namespace: actionETL.Adb
Assembly: actionETL.dll
Syntax
public sealed class AdbConnectionString
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
AdbConnectionString Example and Example Use of ProcessIncomingFilesWorker demonstrates how to use this class.
Properties
ConnectionString
Gets the connection string.
Note: The connection string is set when the connection string factory is created.
Declaration
public string ConnectionString { get; }
Property Value
| Type | Description |
|---|---|
| String |
Provider
Gets the Adb provider.
Declaration
public AdbProvider Provider { get; }
Property Value
| Type | Description |
|---|---|
| AdbProvider |
Methods
CreateCommandBuilder()
Creates a database command builder instance, initialized with a new AdbConnectionBuilder instance from the Provider and ConnectionString properties.
When an AdbCommand is created from the returned builder, it will 'own' the
connection. That AdbCommand must be disposed after use, which will also
automatically dispose the connection.
See Disposing Disposables for details.
To instead get an AdbCommand with an AdbKeepOpenConnectionBuilder, create the
connection builder first (e.g. with CreateKeepOpenConnectionBuilder()),
and then create command builders from the connection builder.
Declaration
public AdbCommandBuilder CreateCommandBuilder()
Returns
| Type | Description |
|---|---|
| AdbCommandBuilder | Returns an |
CreateConnectionBuilder()
Creates an AdbConnectionBuilder instance initialized from the Provider and
ConnectionString properties.
The returned instance can in turn create one AdbConnection instance (which must be disposed), as well as AdbCommandBuilder instances.
Declaration
public AdbConnectionBuilder CreateConnectionBuilder()
Returns
| Type | Description |
|---|---|
| AdbConnectionBuilder | Returns an |
CreateKeepOpenConnectionBuilder()
Creates an AdbKeepOpenConnectionBuilder instance initialized from the Provider
and ConnectionString properties. The returned builder instance must be
explicitly disposed after the associated connection is no longer used. Only when this
instance is disposed will the underlying .NET connection be closed and disposed.
The builder instance is in turn used to create a single AdbKeepOpenConnection database connection, which must also be explicitly disposed when it is no longer used.
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.
Declaration
public AdbKeepOpenConnectionBuilder CreateKeepOpenConnectionBuilder()
Returns
| Type | Description |
|---|---|
| AdbKeepOpenConnectionBuilder | Returns an |
ToString()
Returns a String that represents this instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
With(String)
Create a new instance with the provided connection string using the same provider.
Declaration
public AdbConnectionString With(string connectionString)
Parameters
| Type | Name | Description |
|---|---|---|
| String | connectionString | The connection string. |
Returns
| Type | Description |
|---|---|
| AdbConnectionString |