title: Great difference in Entity Framework query speed. But why?
body: <p>I am writing a method that allows users to search for records from a table based on some criteria. they may not always submit all criteria so i am trying to craft the EF query so that it can be built up in pieces based on what the user has provided as criteria. The relevant piece is here:</p>
  
  <pre><code>using (var db = new EntityModels.My_Entities())
  {
      //very fast
      List&lt;EntityModels.TBLEFFORT&gt; effs = db.TBLEFFORT.Where(a =&gt; a.ANID == "5F180A0000K0").ToList();
  
      //very slow
      IQueryable&lt;EntityModels.TBLEFFORT&gt; query = db.TBLEFFORT.AsQueryable();
      query.Where(a =&gt; a.ANID == "5F180A0000K0");
      List&lt;EntityModels.TBLEFFORT&gt; efforts = query.ToList();
  }
  </code></pre>
  
  <p>The first line runs very quickly and return 150 records or so.
  The second construct takes longer than i'm even willing to wait (at least 2 minutes before i gave up). Why are they so different? I want to use the second construct so i can build upon the query object based on whether a specific criteria was included by the user. What am i missing here?</p>