title: how to print a result of linq query from controller in the view?
body: <p>I have the follow code in the controller</p>
  
  <pre><code>  public ActionResult Linq()
          {
              List&lt;region&gt; Regiones = db.region.ToList();
              List&lt;comuna&gt; Comunas = db.comuna.ToList();
  
              var  resultado = from r in Regiones
                              join c in Comunas on r.r_id equals c.c_region
                              where r.r_id == 8
                              select new
                              {
                                  region = r.r_region,
                                  comuna = c.c_comuna
                              };
              ViewBag.resultado = resultado;
              return View();
          }
  </code></pre>
  
  <p>and this in the view </p>
  
  <pre><code> @{ 
                             foreach(var a in ViewBag.resultado)
                             {
                                &lt;tr&gt;&lt;td&gt;
                                    @a.comuna
                                &lt;/td&gt;&lt;/tr&gt; 
                             }
                         }
  </code></pre>
  
  <p>but when this run, i have the follow error:</p>
  
  <blockquote>
    <p>Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' no contiene una definición para 'comuna'.</p>
  </blockquote>
  
  <p>What happened? how I print all "comuna" in the view?</p>
  
  <p>Thanks!</p>