title: Entity framework loads all records for large table when only a subset is required
body: <p>I have a table that lists all errors and warnings for an device (a hardware device whose details we store in the db).  That is covered by a single <code>DeviceLog</code>.</p>
  
  <p>The <code>DeviceLog</code> table stores both current and archive errors, this means though that for devices with a large archive it is very slow to get out the current error / warning state. </p>
  
  <pre><code>device.Errors = databaseDevice.Errors.Where(
      e =&gt; e.Current &amp;&amp; 
      e.LogEntryType == Models.DeviceLogEntryType.Error)
          .Select(e =&gt; new DeviceErrorLog()).ToList();
  </code></pre>
  
  <p>So the in this current case there are about 5000 entries in <code>DeviceLog</code> for this specific device, but no current ones so <code>device.Errors.Count() == 0</code> but if, in intellisense, I hover over <code>databaseDevice.Errors</code> it shows the actual full count.  </p>
  
  <p>Is this behaviour expected, if so then how can I make this faster as I thought this should be a fast operation especially as I am specifying a very direct and easily searchable subset of the data</p>
  
  <p>To clarify the data structure:</p>
  
  <pre><code>public class DeviceLogEntry
  {        
      public DeviceLogEntryType /* An Enum */ LogEntryType { get; set; }
      public bool Current { get; set; }
  }
  </code></pre>