private string InternalGetConnectionString(string contextName) { StorageContextConfigurationItem storageContextConfigurationItem = StorageContextConfiguration.GetStorageContext(contextName); if (storageContextConfigurationItem == null) { return(null); } string connectionString = storageContextConfigurationItem.ConnectionString; return(GetDescryptedConnectionString(connectionString)); }
public DbConnection GetConnection(string contextName) { _storageContextConfigurationItem = StorageContextConfiguration.GetStorageContext(contextName); string providerInvariantName = _storageContextConfigurationItem.ProviderName; DbProviderFactory providerFactory = DbProviderFactories.GetFactory(providerInvariantName); if (providerFactory == null) { throw new InvalidOperationException(String.Format("The '{0}' provider is not registered on the local machine.", providerInvariantName)); } DbConnection connection = providerFactory.CreateConnection(); connection.ConnectionString = _connectionStringProvider.GetConnectionString(_storageContextConfigurationItem.Name); return(connection); }