title: Determine the type of Object to use to store a Linq Query
body: <p>I am using VB .Net for this, so I don't have access to <code>var</code> or this would be a simple matter.</p>
  
  <p>Right now my query is as follows</p>
  
  <pre><code>Dim errors As IOrderedQueryable(Of IGrouping(Of String, RSError)) = (From e In db.RSErrors 
                                                                       Where e.UserID = "msarchet" 
                                                                       Group e By e.Type Into t = Group).AsEnumerable
  </code></pre>
  
  <p>So I used this query in LinqPad to help me determine what the object would look like. I got back a <code>IOrderQueryable(Of RSError)</code> which then contained a <code>IGrouping(Of String, RSError)</code> for each grouped collection of objects returned by the query.</p>
  
  <p>However I ended up with the current object type of <code>errors</code> as <code>IOrderedQueryable(Of IGrouping(Of String, RSError))</code> because of the cast error I am getting in VS.</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Data.Linq.DataQuery<code>1[VB$AnonymousType_1</code>2[System.String,System.Collections.Generic.IEnumerable<code>1[RSSAdmin2.RSError]]]' to type 'System.Linq.IOrderedQueryable</code>1[System.Linq.IGrouping<code>2[System.String,RSSAdmin2.RSError]]'.</code></p>
  </blockquote>
  
  <p>I'm not sure how to get rid of the VB$AnonymousType_1 Part of the returned object.</p>
  
  <p>Am I even on the right track here or am I missing something completely?</p>