title: Are navigation properties read each time they are accessed? (EF4.1)
body: <p>I am using EF 4.1, with POCOs which are lazy loaded.</p>
  
  <p>Some sample queries that I run:</p>
  
  <pre><code>var discountsCount = product.Discounts.Count();  
  var currentDiscountsCount = product.Discounts.Count(d=&gt;d.IsCurrent);  
  var expiredDiscountsCount = product.Discounts.Count(d=&gt;d.IsExpired);  
  </code></pre>
  
  <p>What I'd like to know, is whether my queries make sense, or are poorly performant:</p>
  
  <p>Am I hitting the database each time, or will the results come from cached data in the DbContext?</p>
  
  <p>Is it okay to access the navigation properties "from scratch" each time, as above, or should I be caching them and then performing more queries on them, for example:</p>
  
  <pre><code>var discounts = product.Discounts;  
  var current = discounts.Count(d=&gt;d.IsCurrent);  
  var expired = discounts.Count(d=&gt;d.Expired);  
  </code></pre>
  
  <p>What about a complicated case like below, does it pull the whole collection and then perform local operations on it, or does it construct a specialised SQL query which means that I cannot reuse the results to avoid hitting the database again:</p>
  
  <pre><code>var chained = discounts.OrderBy(d=&gt;d.CreationDate).Where(d=&gt;d.CreationDate &lt; DateTime.Now).Count();
  </code></pre>
  
  <p>Thanks for the advice!</p>
  
  <p><strong>EDIT based on comments below</strong></p>
  
  <p>So once I call a navigation property (which is a collection), it will load the entire object graph. But what if I filtered that collection using <code>.Count(d=&gt;d...)</code> or <code>Select(d=&gt;d...)</code> or <code>Min(d=&gt;d...)</code>, etc. Does it load the entire graph as well, or only the final data?</p>