title: async Task<IEnumerable> with yield return?
body: <p>The below method doesn't compile. Alternatives?</p>
  
  <pre><code>public static async Task&lt;IEnumerable&lt;object[]&gt;&gt; GetRecordsAsync(
      this Transaction transaction,
      string commandText,
      params SqlParameter[] parameters)
  {
      // Get a SqlDataReader
      var reader = await transaction.GetReaderAsync(commandText, parameters);
      var fieldCount = -1;
      // Begin iterating through records asynchronously
      while (await reader.ReadAsync()) // Note we don't loop until .ReadAsync returns a boolean
      {
          // Grab all the field values out
          if (fieldCount &lt; 0)
              fieldCount = reader.FieldCount;
          var fields = new object[fieldCount];
          reader.GetValues(fields);
          // Yield return the field values from this record
          yield return fields;
      }
  }
  </code></pre>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>The body of 'TransactionExtensions.GetRecordsAsync(Transaction, string, params SqlParameter[])' cannot be an iterator block because 'Task>' is not an iterator interface type</p>
  </blockquote>
  
  <p>I don't see a way to adapt <a href="https://stackoverflow.com/a/6628513/3063273">this answer</a> to a similar sounding (but different) question, because I don't know <em>a priori</em> how many times the loop will go.</p>
  
  <p>Edit: fixed formatting</p>