title: ASP.NET MVC ViewBag list of anonymous class throws error on Count() method
body: <p>I have a serverside code where I'm returning a list of anonymous class from the database:</p>
  
  <pre><code>    public ActionResult DisplayMap()
      {
          ViewBag.Checkins = (from locationUpdate in db.LocationUpdates
                              select new
                              {
                                  locationUpdate,
                                  locationUpdate.User
                              }).ToList();
          return View();
      }
  </code></pre>
  
  <p>At the Razor page, I want to get the count of this list:</p>
  
  <pre><code>@if (ViewBag.Checkins.Count() &gt; 0)
  { ... }
  </code></pre>
  
  <p>However, it throws an error:</p>
  
  <pre><code>An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred 
  in System.Core.dll but was not handled in user code.
  
  Additional information: 'object' does not contain a definition for 'Count'
  </code></pre>
  
  <p>When I type <code>ViewBag.Checkins</code> in immediate window, I get:</p>
  
  <pre><code>ViewBag.Checkins
  {System.Collections.Generic.List&lt;&lt;&gt;f__AnonymousType6&lt;MY_APP.LocationUpdate,MY_APP.User&gt;&gt;}
      [0]: { locationUpdate = {System.Data.Entity.DynamicProxies.LocationUpdate_4532566693B61EF657DDFF4186F1D6802EA1AC8D5267ED245EB95FEDC596E129}, User = {System.Data.Entity.DynamicProxies.User_816C8A417B45FE8609CD1F0076A5E6ECBAB0F309D83D2F8A7119044B1C6060CF} }
  </code></pre>
  
  <p>The <code>Checkins</code> object is indeed a <code>List</code>, and the data is correct. I've tried <code>Count</code>, <code>Length</code> too (without method call, just as properties) but no luck. What am I doing wrong?</p>