private GetConnection ( [ connectionName = null, [ ensureIdentical = null, |
||
connectionName | [ | |
ensureIdentical | [ | |
cancellationToken | ||
return | Task |
public Task<LoadBalancedConnection> GetConnection(
[CanBeNull] string connectionName = null,
[CanBeNull] bool? ensureIdentical = null,
CancellationToken cancellationToken = default(CancellationToken))
{
LoadBalancedConnectionElement connectionElement = string.IsNullOrWhiteSpace(connectionName)
? Connections.FirstOrDefault(c => c.Enabled)
: Connections[connectionName];
if (connectionElement == null)
throw new LoggingException(
() => Resources.DatabaseElement_GetSchemas_No_Connection,
Id);
return connectionElement.GetLoadBalancedConnection(ensureIdentical, cancellationToken);
}
public Task <LoadBalancedConnection> GetConnection( [NotNull] string database, [CanBeNull] string connectionName = null, [CanBeNull] bool?ensureIdentical = null, CancellationToken cancellationToken = default(CancellationToken)) { if (database == null) { throw new ArgumentNullException("database"); } DatabaseElement db = Databases[database]; if ((db == null) || (!db.Enabled)) { return(TaskResult <LoadBalancedConnection> .FromException( new LoggingException( () => Resources.DatabaseConfiguration_GetSqlProgram_DatabaseIdNotFound, database))); } return(db.GetConnection(connectionName, ensureIdentical, cancellationToken)); }