0

Essentially the question boils down to "How can one apply the following raw-SQL-fueled approach in EF6?" (is it even possible?):

How to determine position of row in sql result-set?

Update: This is not what I am looking for:

https://stackoverflow.com/a/1165249/863651

It doesn't employ ROW_NUMBER or something similar in db-side. It uses linq purely on the C# (aka it fetches all results and then enumerates them yikes!)

XDS
  • 3,786
  • 2
  • 36
  • 56
  • Possible duplicate of [How do I add ROW\_NUMBER to a LINQ query or Entity?](https://stackoverflow.com/questions/1165028/how-do-i-add-row-number-to-a-linq-query-or-entity) – CodeMonkey1313 Jun 06 '19 at 18:25

1 Answers1

0

Well if what you need is an index on every result you can simply do

var result = Table.Select((x,i)=> new {val = x, ind = i});

This will essentially append the index of each row to its data, if you wanted the index of a particular id in the table you can do something like

int index = result.where(x => x.id == [someval]).Select(y => y.ind).First();

Where result is the result from the query above ofcourse, note I typed this on my phone the snytax might have a few errors

Shady3cho
  • 27
  • 5