title: EF: Lazy loading, eager loading, and "enumerating the enumerable"
body: <p>I find I'm confused about lazy loading, etc.</p>
  
  <p>First, are these two statements equivalent:</p>
  
  <pre><code>(1) Lazy loading:
  _flaggedDates = context.FlaggedDates.Include("scheduledSchools")
  .Include  ("interviews").Include("partialDayAvailableBlocks")
  .Include("visit").Include("events");
  
  (2) Eager loading:
  _flaggedDates = context.FlaggedDates;
  </code></pre>
  
  <p>In other words, in (1) the "Includes" cause the navigation collections/properties to be loaded along with the specific collection requested, regardless of the fact that you are using lazy loading ... right?</p>
  
  <p>And in (2), the statement will load all the navigation entities even though you do not specifically request them, because you are using eager loading ... right?</p>
  
  <p>Second: even if you are using eager loading, the data will not actually be downloaded from the database until you "enumerate the enumerable", as in the following code:</p>
  
  <pre><code>var dates = from d in _flaggedDates
              where d.dateID = 2
              select d;
  foreach (FlaggedDate date in dates)
  {
  ... etc.
  }
  </code></pre>
  
  <p>The data will not actually be downloaded ("enumerated") until the foreach loop ... right? In other words, the "var dates" line defines the query, but the query is not executed until the foreach loop.</p>
  
  <p>Given that (if my assumptions are correct), what's the real difference between eager loading and lazy loading?? It seems that in either case, the data does not appear until the enumeration. Am I missing something?</p>
  
  <p>(My specific experience is with code-first, POCO development, by the way ... though the questions may apply more generally.) </p>