I'm trying to display a result from a database via via that includes an aggregate value from the same table. i have a table that has Name, Score and Round which holds players names and scores for each particular round. I want to display that in a grid (say I select round 5) but I also want to show the rank of each player which is their total score over all rounds up to and including the selected round.
So far I have two queries - one returns a list of the the names and the sum of their round scores and another that retrieves their name, score for a particular round. I only need the index of the sum though to get the rank, I don't need the sum of the score itself. I'm trying to include the first query in the second query with something like
Rank = r1.FindIndex(r => r.Name == tr.Name)
but I keep getting the error 'LINQ to Entities does not recognize the method 'Int32 FindIndex'. I know why I'm getting this (it can't be compiled into SQL) but I can't figure out how to get around it. So, how can I structure my query so it gets the rows I need from the table but also factors in the correct rank i.e. index of a player in the first query? Any advice?