title: Filling List property of objects in a foreach-loop
body: <p>I'm wondering if filling a list of objects in an object can be done quicker than what i see when i run it.
  I fill the CABCodes- &amp; CABDetails-lists with a simple query using Dapper with .ToList();</p>
  
  <p>So both the lists are in memory, yet the foreach-operation takes around 20 seconds.</p>
  
  <p>CABCodes: ~10,000 objects </p>
  
  <p>CABDetails: ~60,000 objects</p>
  
  <pre><code>List&lt;CABCode&gt; CABCodes = new List&lt;CABCode&gt;();
  List&lt;CABDetail&gt; CABDetails = new List&lt;CABDetail&gt;();
  
  public class CABCode {
      public int Sequence { get; set; }
      public string Code { get; set; }
      public int Group { get; set; }
      public List&lt;CABDetail&gt; Details { get; set; }
  }
  public class CABDetail {
      public int CABSequence { get; set; }
      public int Proptype { get; set; }
      public string Propvalue { get; set; }
  }
  
  foreach (var c in this.CABCodes) {
      c.Details = this.CABDetails.Where(x =&gt; x.CABSequence == c.Sequence).ToList();
  }
  </code></pre>
  
  <p>Is there a far more efficient method of accomplishing this?</p>