title: Get record's row number using Linq
body: <p>I'd like to get a record's row number inside a huge list of records from a table, using Entity Framework 6.</p>
  
  <p>I tried this code:</p>
  
  <pre><code>//var currentUser = my record
  var orderedUsers = dbContext.User.OrderByDescending(u =&gt; u.Age).ToList();
  
  var userIndex = orderedUsers.IndexOf(currentUser);
  </code></pre>
  
  <p>The <code>ToList()</code> method crashes with a timeout, because I assume that this methods loads the whole list in memory.</p>
  
  <p>How can I get this row number using a simpler method with Linq (so, without <code>ToList</code> or mounting everything in memory) ?</p>
  
  <p>For information, my goal is to get a range of record from a start index to another index. Here's the code I wrote to do this:</p>
  
  <pre><code>var result = orderedUsers.Skip(userIndex).Take(30).ToList();
  </code></pre>
  
  <p>Thanks</p>