title: Why casting IQueryable to .toList() include data to object DbContext?
body: <p>I have a code example that is using entity-framework</p>
  <p>This one is working:</p>
  <pre><code>    public ActionResult Index()
      {
          BlogContext dbContext = new BlogContext();
          dbContext.Posts.Include(a =&gt; a.Tags).ToList();
          return View(dbContext.Posts.ToList());
      }
  </code></pre>
  <p>and this one is not:</p>
  <pre><code>    public ActionResult Index()
      {
          BlogContext dbContext = new BlogContext();
          dbContext.Posts.Include(a =&gt; a.Tags);
          return View(dbContext.Posts.ToList());
      }
  </code></pre>
  <p>So I do not understand, why only casting to <code>List</code> is enough to include tags from the model (<code>List&lt;Tags&gt;</code>), I would understand if it would be like this, which is fine too (and I am using that! Question is not about code formating!):</p>
  <pre><code>    public ActionResult Index()
      {
          BlogContext dbContext = new BlogContext();
          var model=dbContext.Posts.Include(a =&gt; a.Tags).ToList();
          return View(model);
      }
  </code></pre>
  <p>but it does not need to be. So my question is:
  <strong>Why casting IQueryable to toList is including data to object <code>dbContext</code>?</strong> I know that in entity-framework we are working with extensions but as far as I remember extensions return values not assign one to an object.</p>
  <p>This is my partial view that is crashing:</p>
  <pre><code>@using BlogWeb.Models
  @model Post
  
  
      &lt;h1&gt;@Model.Title&lt;/h1&gt;
      &lt;p class=&quot;lead&quot;&gt;
          by &lt;a href=&quot;#&quot;&gt;1234&lt;/a&gt;
      &lt;/p&gt;
      &lt;hr&gt;
      &lt;p&gt;@Model.Created&lt;/p&gt;
      &lt;p class=&quot;lead&quot;&gt;
          @Model.Body
      &lt;/p&gt;
      @Html.Partial(&quot;_Tags&quot;, Model.Tags) -&lt;&lt; this is what is throwing error
      &lt;hr&gt;
  </code></pre>
  <p>And this is a partial tag view</p>
  <pre><code>@using BlogWeb.Models
  @model List&lt;Tag&gt;
  @foreach (Tag tag in Model)
  {
      @Html.Label('#' + tag.TagName)
      @Html.Raw(&quot; &quot;)
  }
  </code></pre>
  <p>Error message :</p>
  <blockquote>
  <p>The model item passed into the dictionary is of type
  'BlogWeb.Models.Post', but this dictionary requires a model item of
  type 'System.Collections.Generic.List`1[BlogWeb.Models.Tag]'.</p>
  </blockquote>