title: Entity Framework - slow when using a simple query
body: <p>I have a simple class in entity framework as follows:</p>
  
  <pre><code>public class Merchandising
  {
      public int Id { get; set; }
  
      public int Index { get; set; }    
  
      public int CategoryId { get; set; }
  
      public int? CardId { get; set; }  
  }
  </code></pre>
  
  <p>In the database this has approximately 1000 rows, and a direct query takes less than a second, but when I execute this statement, it takes up to 55 seconds to run - which I find very bizarre. Can anyone throw any light on this?</p>
  
  <pre><code>var mm = a.Merchandisings.ToList();    
  var m = mm.Where(f =&gt; f.CategoryId == catId).ToList();
  </code></pre>
  
  <p><code>catId</code> is an integer value, and mm takes a fraction of a second to execute. There are approximately 1000 rows returned by mm, and 40 rows returned by m. M takes around 55 seconds to execute. </p>
  
  <p>I am assuming that although the <code>CategoryId</code> and <code>CardId</code> both link to other classes (and are big data objects), data isn't loaded because there is no lazy loading.</p>
  
  <p>I really can't understand why it is taking so long for m to execute, and I guess this is to do with some lack of knowledge with equity framework. Can anyone assist?</p>