title: Doing a Cast Within a LINQ Query
body: <p>Is it possible to do a cast within a LINQ query (for the compiler's sake)?</p>
  
  <p>The following code isn't terrible, but it would be nice to make it into one query:</p>
  
  <pre><code>Content content = dataStore.RootControl as Controls.Content;
  
  List&lt;TabSection&gt; tabList = (from t in content.ChildControls
                              select t).OfType&lt;TabSection&gt;().ToList();
  
  List&lt;Paragraph&gt; paragraphList = (from t in tabList
                                   from p in t.ChildControls
                                   select p).OfType&lt;Paragraph&gt;().ToList();
  
  List&lt;Line&gt; parentLineList = (from p in paragraphList
                               from pl in p.ChildControls
                               select pl).OfType&lt;Line&gt;().ToList();
  </code></pre>
  
  <p>The code continues on with a few more queries, but the gist is I have to create a List out of each query in order for the compiler to know that all of the objects in <code>content.ChildControls</code> are of type <code>TabSection</code> and all of the objects in <code>t.ChildControls</code> are of type <code>Paragraph</code>...and so on and and so forth.</p>
  
  <p>Is there a way within the LINQ query to tell the compiler that <code>t</code> in <code>from t in content.ChildControls</code> is a <code>TabSection</code>?</p>