title: How to map multiple records from a single SP with Dapper-dot-net
body: <p>I'd like to use Dapper in a situation where the execution of a single stored procedure will return 50 multiple separate selects, none of the individual result sets will be very wide, maybe 20 or 30 columns at most. The code below is from the Dapper Tests and I'm wondering if this example is a good prototype to use.</p>
  
  <p>Thank you,
  Stephen </p>
  
  <pre><code>public void TestMultiMap()
          {
              var createSql = @"
                  create table #Users (Id int, Name varchar(20))
                  create table #Posts (Id int, OwnerId int, Content varchar(20))
  
                  insert #Users values(99, 'Sam')
                  insert #Users values(2, 'I am')
  
                  insert #Posts values(1, 99, 'Sams Post1')
                  insert #Posts values(2, 99, 'Sams Post2')
                  insert #Posts values(3, null, 'no ones post')";
  
                  connection.Execute(createSql);
  
              var sql = @"select * from #Posts p 
                        left join #Users u on u.Id = p.OwnerId 
                        Order by p.Id";
  
              var data = connection.Query&lt;Post, User, Post&gt;(sql, (post, user) =&gt; { post.Owner = user; return post; }).ToList();
              var p = data.First();
  
              p.Content.IsEqualTo("Sams Post1");
              p.Id.IsEqualTo(1);
              p.Owner.Name.IsEqualTo("Sam");
              p.Owner.Id.IsEqualTo(99);
  
              data[2].Owner.IsNull();
  
             connection.Execute("drop table #Users drop table #Posts");
      }
  </code></pre>
  
  <p>EDIT</p>
  
  <p>Here is a sample based on Marcs answer.</p>
  
  <pre><code>        const string sql = @"__sp_GetMISMOLoanInfo";
          using (var multi = _connection.QueryMultiple(sql, new { loannum = "3192381" }, commandType: CommandType.StoredProcedure))
          {
             var address = multi.Read&lt;ADDRESS&gt;().Single();
             var amortizationRule = multi.Read&lt;AMORTIZATION_RULE&gt;().Single();
             var appraiserLicense = multi.Read&lt;APPRAISER_LICENSE&gt;().Single();
             var automatedUnderwriting = multi.Read&lt;AUTOMATED_UNDERWRITING&gt;().Single();
             var avm = multi.Read&lt;AVM&gt;().Single();
             var borrowerDetail = multi.Read&lt;BORROWER_DETAIL&gt;().Single();
          }
  </code></pre>