How To Project a Line Number Into Linq Query Results
问题 How can I project the row number onto the linq query result set. Instead of say: field1, field2, field3 field1, field2, field3 I would like: 1, field1, field2, field3 2, field1, field2, field3 Here is my attempt at this: public List<ScoreWithRank> GetHighScoresWithRank(string gameId, int count) { Guid guid = new Guid(gameId); using (PPGEntities entities = new PPGEntities()) { int i = 1; var query = from s in entities.Scores where s.Game.Id == guid orderby s.PlayerScore descending select new