title: best way to extract a one to many relationship with dapper dot net orm?
body: <p>I have two classes 'Product' and 'Seller'.</p>
  
  <pre><code>public class Product
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public decimal Price { get; set; }
  
      public Seller Seller { get; set; }
      public int? SellerId { get; set; }
  }
  public class Seller
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public List&lt;Product&gt; Products { get; set; }
  }
  </code></pre>
  
  <p>I want to extract a list of Sellers with all of their products using dapper.</p>
  
  <p>Currently i'm doing it like this :</p>
  
  <pre><code>Dictionary&lt;int, Seller&gt; dic = new Dictionary&lt;int, Seller&gt;();
          Conn.Query&lt;Seller, Product, int&gt;
              (@"select s.*,p.* from Sellers s Join Products p 
                  on p.SellerId = s.Id",
              (s, p) =&gt; {
                  if (dic.ContainsKey(s.Id))
                      dic[s.Id].Products.Add(p);
                  else
                  {
                      s.Products = new List&lt;Product&gt;();
                      s.Products.Add(p);
                      dic.Add(s.Id, s);
                  }
                  return s.Id; 
              });
          var sellers = dic.Select(pair =&gt; pair.Value);
  </code></pre>
  
  <p>Is there any better way?</p>