title: MVC ViewBag: Is access to DB with ViewBag in Controller faster than direct access in View
body: <p>I am wondering what is faster. Should i store information that i queried from DB into a ViewBag and then access and display it in a View, or should i make a query directly in View. 
  Controller is the middle layer in MVC so it would seem logical to me, that accessing DB in controller should be faster.</p>
  
  <p><strong>Example:</strong></p>
  
  <p><strong>1)</strong> In a Controller i access the DB and put the information into a ViewBag so that i can display it in View.</p>
  
  <p>controller:</p>
  
  <pre><code>EVENT e = db.EVENT.Find(id);
  ViewBag.event = e;
  
  if (e.poster_id != null)
  {
      poster = e.DATA.path;
  }
  ViewBag.dict_poster = poster;
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;p&gt;POSTER: @ViewBag.dict_poster;&lt;/p&gt;
  </code></pre>
  
  <p><strong>2)</strong> In Controller i put only the general data from DB into ViewBag and that access it in View.</p>
  
  <p>controller:</p>
  
  <pre><code>EVENT e = db.EVENT.Find(id);
  ViewBag.event = e;
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;p&gt;
      @if(ViewBag.event.poster_id != null)
      {
          @ViewBag.event.DATA.path;
      }
  &lt;/p&gt;
  </code></pre>
  
  <ul>
  <li>What is better and more appropriate to use? What is faster? </li>
  <li>What if i have a very branched DB and i have to store everything into "ViewBag.e", is it better and faster to store individual values into ViewBags and than access them in Views or is direct access from a View faster? </li>
  <li>What about Lists? (storing DB information into a list, putting it in a ViewBag and than accessing it in the View)</li>
  </ul>
  
  <p>I am grateful for your answers and added explanation....</p>