title: How to use transaction across multiple method calls with Dapper?
body: <p>I need to wrap some calls to methods that are doing <code>async</code> updates and inserts into my database.  All of the methods use this pattern for running the code:</p>
  
  <pre><code> using (IDbConnection conn = Connection)
              {
                  conn.Open();
                  //TODO:  Table item quantity for the QTYALLOC field
                  var sql = //sql statement;
                  int x = await conn.ExecuteAsync(sql);
                  return x &gt; 0;
              }
  </code></pre>
  
  <p>Right now all of the methods return a <code>boolean</code>.  I want to wrap the calls in a transaction and either commit or rollback</p>
  
  <pre><code>                    await [InsertRecord];
                      //add the audit record
                      var addAudit = await [Insert Audit Record];
                      var updateOrd = await [Update Record]
                      var changePickStatus = await [Update Record]
                      if (locs.First().QTYTOTAL - ord.QTYPICKED &lt;= 0)
                      {
                          await [Delete Record]; //delete the record
  
                      }
                      else
                      {
                          //decrement the quantity for the location and update.
                          locs.First().QTYTOTAL -= ord.QTYPICKED;
                          await [Update Record]
  
                      }
  </code></pre>
  
  <p>I put the calls to the methods in the square [] brackets.  Right now each call returns a <code>boolean</code> to indicate it was successful or failed, I would like to wrap all these calls in one transaction to commit or rollback based on the outcome of each call.  I don't want to put all the SQL statements into one large call if I can help it, they are long and complex.  Can I pass in a transaction to each method call and apply it to each <code>ExecuteAsync</code> operation?  If so what would I pass back from the method to indicate success or failure?</p>