Table of Contents

Class DatabaseConnectionCache

Namespace
Ecng.Data
Assembly
Ecng.Data.dll

Represents a cache for DatabaseConnectionPair objects.

public class DatabaseConnectionCache : IPersistable
Inheritance
DatabaseConnectionCache
Implements
Inherited Members
Extension Methods

Constructors

DatabaseConnectionCache()

public DatabaseConnectionCache()

Properties

Connections

Gets all database connection pairs.

public IEnumerable<DatabaseConnectionPair> Connections { get; }

Property Value

IEnumerable<DatabaseConnectionPair>

Methods

DeleteConnection(DatabaseConnectionPair)

Deletes the specified database connection pair from the cache.

public bool DeleteConnection(DatabaseConnectionPair connection)

Parameters

connection DatabaseConnectionPair

The database connection pair to delete.

Returns

bool

True if the connection was successfully removed; otherwise, false.

GetOrAdd(string, string)

Retrieves an existing connection matching the specified provider and connection string or adds a new connection if it does not exist.

public DatabaseConnectionPair GetOrAdd(string provider, string connectionString)

Parameters

provider string

The database provider.

connectionString string

The connection string.

Returns

DatabaseConnectionPair

The corresponding DatabaseConnectionPair.

Load(SettingsStorage)

Loads the database connection pairs from the specified settings storage.

public void Load(SettingsStorage storage)

Parameters

storage SettingsStorage

The settings storage to load from.

Save(SettingsStorage)

Saves the database connection pairs to the specified settings storage.

public void Save(SettingsStorage storage)

Parameters

storage SettingsStorage

The settings storage to save to.

Events

ConnectionCreated

Occurs when a new database connection pair is created.

public event Action<DatabaseConnectionPair> ConnectionCreated

Event Type

Action<DatabaseConnectionPair>

ConnectionDeleted

Occurs when a database connection pair is deleted.

public event Action<DatabaseConnectionPair> ConnectionDeleted

Event Type

Action<DatabaseConnectionPair>

Updated

Occurs when the connection cache is updated.

public event Action Updated

Event Type

Action