title: Performance issue with LINQ when getting recent data by hours on a large set
body: <p>I have a generic <code>List&lt;T&gt; ticker</code> collection where <code>T</code> object has, amongst others, property <code>AsOfDate</code> which is <code>DateTime</code>.
  This list collection can have >20k items. </p>
  
  <p>I am getting the most recent hours from the <code>AsOfDate</code>, where the amount is specified by a variable <code>amount</code> of type <code>int</code> (e.g. 3)</p>
  
  <p>My code is: </p>
  
  <pre><code>from x in ticker
  let y = ticker.OrderByDescending(y =&gt; x.AsOfDate).First()
  where x.AsOfDate &gt; y.AsOfDate.AddHours(-amount)
  orderby x.AsOfDate descending
  select x).ToList();
  </code></pre>
  
  <p>When working with a small dataset (say 200 items in list), this works fine. However, when working with over 20,000 items in the list, I am witnessing significant speed issues (3 minutes).</p>
  
  <p>Why is the LINQ query taking so long? And how can I improve it?</p>