title: Dapper async and transaction
body: <p>I'm trying to figure out how to properly use the Dapper with the transaction. But I still think I'm doing something wrong. All the examples I found are without using async.</p>
  
  <p>Could somebody advise me how to do it right?</p>
  
  <pre><code>class DapperAsyncTransaction
  {
      private readonly IDbConnection _dbConnection;
      private IDbTransaction _dbTransaction;
  
      private IDbConnection Connection =&gt; _dbTransaction.Connection;
  
      /// &lt;summary&gt;
      /// Constructor
      /// &lt;/summary&gt;
      /// &lt;param name="dbConnection"&gt;&lt;/param&gt;     
      public DapperAsyncTransaction(
          IDbConnection dbConnection)
      {
          _dbConnection = dbConnection;
          _dbConnection.Open();
          _dbTransaction = _dbConnection.BeginTransaction();
      }
  
      public async Task Execute()
      {
          try
          {
              await Connection.ExecuteAsync(
              @"insert into Persons(Name, Surname) values" +
              "(@Name, @Surname)",
              param: new { Name = "John", Surname = "Doe" },
              transaction: _dbTransaction);
  
  
              _dbTransaction.Commit();
          }
          catch (Exception)
          {
              _dbTransaction.Rollback();
          }
          finally
          {
              _dbTransaction.Dispose();
              _dbTransaction = _dbConnection.BeginTransaction();
          }
      }
  }
  </code></pre>