title: Using LINQ to get the results from another LINQ collection
body: <p>I have a LINQ statement which pulls the top N record IDs from a collection and then another query which pulls all records which have those IDs. It feels very clunky and inefficient and i was wondering if there might be a more succinct, LINQy way to get the same results</p>
  
  <pre><code>var records = cache.Select(rec =&gt; rec.Id).Distinct().Take(n);
  
  var results = cache.Where(rec =&gt; records.Contains(rec.Id));
  </code></pre>
  
  <p>FYI - there will be multiple records with the same ID, which is why there is the Distinct() and why i can't use a simple Take() in the first place.</p>
  
  <p>Thanks!</p>