title: Does Entity Framework query the database multiple times if I use different fields of the same Linq query at different times?
body: <p>I tried the Internet and the SOF but couldn't locate a helpful resource. Perhaps I may not be using correct wording to search. If there are any previous questions I have missed due to this reason please let me know and I will take this question down.</p>
  
  <hr>
  
  <p>I am dealing with a busy database so I am required to send less queries to the database.</p>
  
  <p>If I access different columns of the same Linq query from different levels of the code then is Entity Framework smart enough to foresee the required columns and bring them all or does it call the db twice?</p>
  
  <h2>eg.</h2>
  
  <pre><code>var query = from t1 in table_1
              join t2 in table_2 on t1.col1 equals t2.col1
              where t1.EmployeeId == EmployeeId
              group new { t1, t2 } by t1.col2 into grouped
              orderby grouped.Count() descending
              select new { Column1 = grouped.Key, Column2 = grouped.Sum(g=&gt;g.t2.col4) };
  
  var records = query.Take(10);
  
  // point x
  var x = records.Select(a =&gt; a.Column1).ToArray();
  
  var y = records.Select(a =&gt; a.Column2).ToArray();
  </code></pre>
  
  <p>Does EF generate query the database twice to faciliate x and y (send a query first to get Column1, and then send another to get Column2) or is it smart enough to know it needs both Columns to be materialised and bring them both at <strong>point x</strong>?</p>
  
  <p><strong>Added to clarify the intention of the question:</strong></p>
  
  <p>I understand I can simply add a greedy method to the end of query.Take(10) and get it done but I am trying to understand if the approach I try (and in my opinion, more elegant) does work of if not what makes EF to make two queries please.</p>