title: When do chained linq queries execute sql?
body: <p>Linq to SQL doesn't actually run the sql until the result is enumerated, that I get.  However, in this example below when does that happen?  Are these all bundled up into one giant query some how or does this seriously pull most of two tables into memory so it can execute the last line?</p>
  
  <pre><code>result = _repository.LocationHandler.Locations(id).Where(x =&gt; x.IsActive);
  
  paymentServiceProfiles = _repository.Context.PaymentServiceProfiles.Where(x =&gt; !x.IsDeleted &amp;&amp; x.IsActive);
  
  terminals = _repository.TerminalHandler.Terminals().Where(x =&gt; x.IsActive &amp;&amp; x.PaymentServiceProfiles.Intersect(paymentServiceProfiles).Any());
  
  result = result.Where(x =&gt; terminals.Count(y =&gt; y.LocationId == x.Id) &gt; 0);
  </code></pre>