title: How can I get the index of an item in an IOrderedQueryable?
body: <p><strong>Background</strong>: 
  I'm designing a list-like control (WinForms) that's backed by a <code>DbSet</code>. A chief requirement is that it <em>doesn't</em> load the entire list into local memory. I'm using a <code>DataGridView</code> in virtual mode as the underlying UI. I'm planning to implement the <code>CellValueNeeded</code> function as <code>orderedQueryable.ElementAt(n)</code>.</p>
  
  <p><strong>Problem</strong>: 
  I need to allow the control's consumer to get/set the currently-selected value, by value rather than by index. Getting is easy--it's the same as the CellValueNeeded operation--but setting is harder: it requires me to get the index of a given element. There's not a built-in <code>orderedQueryable.FirstIndexOf(value)</code> operation, and although I could theoretically fake it with some sort of <code>orderedQueryable.SkipWhile</code> shenanigans where the expression has a side-effect, in practice the DbSet's query provider probably doesn't support doing that.</p>
  
  <p><strong>Questions</strong>:
  Is there an efficient way to get the index of a particular value within an <code>IOrderedQueryable</code>? How?</p>
  
  <p>(If this approach turns out to be untenable, I'd settle for suggestions on how I might restructure the problem to make it solvable.)</p>
  
  <p><strong>Side notes</strong>:
  Elements can be inserted and removed from the list, in which case the old indices will be invalid--that's acceptable, since they're never exposed to the consumer. It's an error for the consumer to attempt to select an item that isn't actually in the list, and actually the consumer would have gotten the item from the list in the first place (although perhaps the indices have changed since then).</p>