예제 #1
0
        private string InternalGetConnectionString(string contextName)
        {
            StorageContextConfigurationItem storageContextConfigurationItem = StorageContextConfiguration.GetStorageContext(contextName);

            if (storageContextConfigurationItem == null)
            {
                return(null);
            }
            string connectionString = storageContextConfigurationItem.ConnectionString;

            return(GetDescryptedConnectionString(connectionString));
        }
예제 #2
0
        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);
        }