DatabaseConnectionCache
Ecng.Data
Represents a cache for DatabaseConnectionPair objects.
Implementa: IPersistable
Propiedades
Connections
public IEnumerable<DatabaseConnectionPair> Connections { get; }
value = databaseConnectionCache.Connections
Gets all database connection pairs.
Métodos
DeleteConnection
public bool DeleteConnection(DatabaseConnectionPair connection)
result = databaseConnectionCache.DeleteConnection(connection)
Deletes the specified database connection pair from the cache.
- connection
- The database connection pair to delete.
Devuelve: True if the connection was successfully removed; otherwise, false.
GetOrAdd
public DatabaseConnectionPair GetOrAdd(string provider, string connectionString)
result = databaseConnectionCache.GetOrAdd(provider, connectionString)
Retrieves an existing connection matching the specified provider and connection string or adds a new connection if it does not exist.
- provider
- The database provider.
- connectionString
- The connection string.
Devuelve: The corresponding DatabaseConnectionPair.
Load
public void Load(SettingsStorage storage)
databaseConnectionCache.Load(storage)
Loads the database connection pairs from the specified settings storage.
- storage
- The settings storage to load from.
Save
public void Save(SettingsStorage storage)
databaseConnectionCache.Save(storage)
Saves the database connection pairs to the specified settings storage.
- storage
- The settings storage to save to.
Eventos
ConnectionCreated
public event Action<DatabaseConnectionPair> ConnectionCreated
databaseConnectionCache.ConnectionCreated += handler
Occurs when a new database connection pair is created.
ConnectionDeleted
public event Action<DatabaseConnectionPair> ConnectionDeleted
databaseConnectionCache.ConnectionDeleted += handler
Occurs when a database connection pair is deleted.
Updated
public event Action Updated
databaseConnectionCache.Updated += handler
Occurs when the connection cache is updated.