title: Unable to cast object of type in MVC 3.0 Razor
body: <p>I am new MVC 3.0 Razor.  I am using LINQ to get the details of profiles.</p>
  
  <p>In the controller i am using</p>
  
  <pre><code>  var q = from m in networks.Entities
                      join o in networks.EntityTypes on m.EntityTypeIdFk 
                      where m.Status == 1
                      orderby m.EntityName
                      select new { m.EntityName,m.EntityDescription,o.EntityTypeName };
  
              ViewBag.EntitiesName = q.ToList();
  </code></pre>
  
  <p>on the View i m using</p>
  
  <pre><code>@foreach (var res in ViewBag.EntitiesName)
      {
          &lt;tr&gt;
              &lt;td&gt;@res.EntityName&lt;/td&gt;
              &lt;td&gt;@res.EntityDescription&lt;/td&gt;
              &lt;td&gt;@res.EntityTypeName&lt;/td&gt;
          &lt;/tr&gt;
      }
  </code></pre>
  
  <p>in the @res i m getting the resultant array. But still i m getting error "Unable to cast object of type"</p>
  
  <p>Please Help me to resolve this.</p>
  
  <p>Thanks,
  Saloni</p>