title: Dapper Reader Disposed Exception
body: <p>I did extend the GridReader with the code below;</p>
  
  <pre><code> /// &lt;summary&gt;
  /// 
  /// &lt;/summary&gt;
  public static class Extentions
  {
      /// &lt;summary&gt;
      /// Maps the specified reader.
      /// &lt;/summary&gt;
      /// &lt;typeparam name="TFirst"&gt;The type of the first.&lt;/typeparam&gt;
      /// &lt;typeparam name="TSecond"&gt;The type of the second.&lt;/typeparam&gt;
      /// &lt;typeparam name="TKey"&gt;The type of the key.&lt;/typeparam&gt;
      /// &lt;param name="reader"&gt;The reader.&lt;/param&gt;
      /// &lt;param name="firstKey"&gt;The first key.&lt;/param&gt;
      /// &lt;param name="secondKey"&gt;The second key.&lt;/param&gt;
      /// &lt;param name="addChildren"&gt;The add children.&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public static IEnumerable&lt;TFirst&gt; Map&lt;TFirst, TSecond, TKey&gt;
   (
   this Dapper.SqlMapper.GridReader reader,
   Func&lt;TFirst, TKey&gt; firstKey,
   Func&lt;TSecond, TKey&gt; secondKey,
   Action&lt;TFirst, IEnumerable&lt;TSecond&gt;&gt; addChildren
   )
      {
          var first = reader.Read&lt;TFirst&gt;().ToList();
          var childMap = reader
              .Read&lt;TSecond&gt;()
              .GroupBy(s =&gt; secondKey(s))
              .ToDictionary(g =&gt; g.Key, g =&gt; g.AsEnumerable());
  
          foreach (var item in first)
          {
              IEnumerable&lt;TSecond&gt; children;
              if (childMap.TryGetValue(firstKey(item), out children))
              {
                  addChildren(item, children);
              }
          }
  
          return first;
      }
  }
  </code></pre>
  
  <blockquote>
    <p>The reader has been disposed; this can happen after all data has been consumed</p>
  </blockquote>
  
  <p>the pint here then when the method is called the reader reads all data in the first time but win the method is entered </p>
  
  <pre><code>var first = reader.Read&lt;TFirst&gt;().ToList();
  </code></pre>
  
  <p>this line give the exception above. so is there any way to keep dapper reader alive to except the query.</p>
  
  <p>thanks in advance .</p>
  
  <p>Note; the method is called like this </p>
  
  <pre><code>  var sql = (@"SELECT *  
                                FROM [pubs].[dbo].[authors] as a
                                right join pubs.dbo.titleauthor as b 
                                ON a.au_id = b.au_idT");
  
          var data = connection.QueryMultiple(sql).Map&lt;authors, titleauthor, string&gt;(
              au =&gt; au.au_id,
              tit =&gt; tit.au_idT,
              (au, tits) =&gt; { au.titleauthor = tits; });
  </code></pre>