private static LazyDatabaseConnection CreateConnection( ProviderConfigElement provider) { LazyDatabaseConnection conn = null; try { ConstructorInfo connCtor = Type.GetType( provider.ConnectionType).GetConstructor( new Type[] { typeof(string) }); ConstructorInfo adapCtor = Type.GetType( provider.AdapterType ).GetConstructor( new Type[] { } ); conn = new LazyDatabaseConnection( (IDbConnection)connCtor.Invoke( new object[] { provider.ConnectionString } ), (IDbDataAdapter)adapCtor.Invoke( null), provider.CloseDelay, provider.IsDistributed); } catch( Exception ex) { throw new DataAccessConnectionException( "Error attempting to create an object of type " + provider.ConnectionString, ex ); } return conn; }
private DataAccess( LazyDatabaseConnection conn ) { _connection = conn; }