title: Selecting both parent and child items when querying child properties
body: <p>In my data structures I have the following classes:</p>
  
  <pre><code>public partial class Item
  {
      // stuff
      public int QuoteId { get; set; }
      public virtual ItemType ItemType { get; set; }
  }
  
  public partial class ItemType
  {
      //stuff
      public virtual ICollection&lt;Item&gt; Items { get; set; }
  }
  </code></pre>
  
  <p>What I want to do is get a list of all the ItemTypes, each of which has its Items collection populated according to a QuoteId.</p>
  
  <p>So, for example if there are three item types, only two of which have items with a quote Id of 50:</p>
  
  <ul>
  <li>ItemType1
  
  <ul>
  <li>Item.QuoteId == 50</li>
  </ul></li>
  <li>ItemType2</li>
  <li>ItemType3
  
  <ul>
  <li>Item.QuoteId == 50</li>
  </ul></li>
  </ul>
  
  <p>I've managed to get something close with this query:</p>
  
  <pre><code>r.ItemTypes.Select(x =&gt; x.Items.Where(i =&gt; i.QuoteId == CurrentQuote.QuoteId));
  </code></pre>
  
  <p>But what this gives you (as you might expect, since I'm <code>Select</code>ing on Item) is an <code>IEnumerable&lt;IEnumerable&lt;Item&gt;&gt;</code>. This has the structure that I'm after but doesn't have the ItemType data.</p>
  
  <p>I realise this is a dumb question, but I'm frustrated by my inability to get the answer.</p>