title: How to properly use async methods on SqlConnection and SqlDataReader?
body: <p>I am porting some old ASP.NET code to .NET 4.5. I am used to using SqlConnection/SqlCommand/SqlDataReader the old fashioned way. Now I am looking at using async primitives in hopes of better performance.</p>
  
  <p>Here is my old code for opening a connection:</p>
  
  <pre><code>    static DBWrapper Open(string connKey) {
          string connStr = WebConfigurationManager.ConnectionStrings[connKey].ConnectionString;
          SqlConnection c = new SqlConnection(connStr);
          c.Open();
          DBWrapper retVal = new DBWrapper();
          retVal._c = c;
          return retVal;
      }
  </code></pre>
  
  <p>Class DBWrapper is just a thin wrapper over SqlConnection that has some extra methods I need.</p>
  
  <p>Here is how I converted to the new async style:</p>
  
  <pre><code>    static async Task&lt;DBWrapper&gt; Open(string connKey) {
          string connStr = WebConfigurationManager.ConnectionStrings[connKey].ConnectionString;
          SqlConnection c = new SqlConnection(connStr);
          var v = c.OpenAsync();
          DBWrapper retVal = new DBWrapper();
          await v;
          retVal._c = c;
          return retVal;
      }
  </code></pre>
  
  <p>Basically, while the connection is being opened, I am able to create a new DBWrapper object concurrently. </p>
  
  <p>What I am confused is if this function really performs better or worse. The overhead of task creation and waiting on it may be much more than the time it takes to create a new DBWrapper object. Whether or not I use async, I am ultimately returning a fully built connection object anyway.</p>
  
  <p>Here is a method that returns the list of users from the database:</p>
  
  <pre><code> List&lt;MyUsers&gt; getUsers() {
       using(SqlCommand cmd ...) {
         using(SqlDataReader reader ...) {
            while(reader.Read() {
               ... Fill the list
            }
         }
   }
  </code></pre>
  
  <p>I can convert this method as well into async style as well:</p>
  
  <pre><code>while (await reader.ReadAsync())
    ... Fill the list
  }
  </code></pre>
  
  <p>Once again I don't see any performance gains. In fact, in the second example, I don't even do anything else concurrently while waiting on ReadAsync().</p>
  
  <p>Is this the correct approach or is there a better way to use async paradigm with database connections and queries? </p>