public async Task<IDbConnection> GetConnectionAsync() {
if (this.isDisposed) {
throw new ObjectDisposedException("Session");
}
if (this.connection.State == ConnectionState.Closed || this.connection.State == ConnectionState.Connecting) {
using (await this.asyncConnectionOpenLock.LockAsync()) {
if (this.connection.State == ConnectionState.Closed) {
await ((DbConnection)this.connection).OpenAsync();
}
}
}
if (this.connection.State != ConnectionState.Open) {
throw new Exception("Connection in unknown state");
}
return this.connection;
}