title: Looping through a Linq Result Set with Multiple Joins
body: <p>I have a complex LINQ query like</p>
  
  <pre><code>        var results = from obj1 in context.ProcessBases
                        join obj2 in context.InspectorArticles
                        on obj1.ID equals obj2.ProcessBaseID
                        join obj3 in context.InspectorSamples
                        on obj2.ID equals obj3.InspectorArticleID
                        where obj1.ID == _processBaseID
                        select new {obj1, obj2, obj3,};
  </code></pre>
  
  <p>Now this result set will have only <strong>ONE</strong> <code>ProcessBases</code>, each <code>ProcessBase</code> will have <strong>MULTIPLE</strong> <code>InspectorArticles</code> and each <code>InspectorArticle</code> will have <strong>MULTIPLE</strong> <code>InspectorSamples</code>. So when I loop through the result set, I want to loop through each <code>InspectorArticle</code>, and then loop through each <code>InspectorSample</code> that belongs to that <code>InspectorArticle</code>, something like:</p>
  
  <pre><code>        foreach (InspectorArticle _iart in results.First().obj2)
          {
            ...          
              foreach (InspectorSample _isamp in results.First().obj3)
              {
                 ...
              }
  
          }
  </code></pre>
  
  <p>But since I've called a <code>.First()</code> on my result set obviously I get this exception:</p>
  
  <blockquote>
    <p>foreach statement cannot operate on variables of type x because x does
    not contain a public definition for 'GetEnumerator'  </p>
  </blockquote>
  
  <p>So how can I loop through each instance of <code>InspectorArticle</code>, and then loop through the number of <code>InspectorSamples</code> for that article? </p>
  
  <p>Thanks.</p>