I'm define a connection provider by inhering the DriverConnectionProvider and have the GetConnection() overriden to open the db connection and everything working fine. Now I'm trying to use the async version of the same method to open the connection but that doesn't seems to work. Can some one help me on this?
return Fluently.Configure()
.Database(
OracleManagedDataClientConfiguration.Oracle10.Provider<OracleConnectionProvider>().Driver<MiniProfilerOracleDriver>()
)
.Mappings(cfg =>
{
cfg.FluentMappings.AddFromAssemblyOf<NHibernateSessionSource>();
})
.BuildConfiguration();
public class OracleConnectionProvider: DriverConnectionProvider
{
// This works
public override DbConnection GetConnection()
{
//var connection = new ProfiledDbConnection(base.CreateConnection() as DbConnection, MiniProfiler.Current).WrappedConnection;
var connection = (DbConnection)new ProfiledDbConnection(new OracleConnection(defaultConnectionString), MiniProfiler.Current);
connection.Open();
return connection;
}
// This doesn't work
public override async Task<DbConnection> GetConnectionAsync(CancellationToken cancellation = default)
{
var connection = (DbConnection)new ProfiledDbConnection(new OracleConnection(defaultConnectionString), MiniProfiler.Current);
await connection.OpenAsync(cancellation);
return connection;
}
}
How can I make sure that the async works is invoked while opening the DB connection ?