title: How to get row number via LINQ using Entity framework?
body: <p>Hope someone can help me out here as I'm a little stuck.</p>
  
  <p>I'm building a service in front of a hiscore database for a game.</p>
  
  <p>The database have the following two tables:</p>
  
  <pre><code>CREATE TABLE [dbo].[PB_HiscoreEntry] (
      [Id]          UNIQUEIDENTIFIER NOT NULL,
      [PlayerId]    UNIQUEIDENTIFIER NOT NULL,
      [Score]       INT              NOT NULL,
      [DateCreated] DATETIME         NOT NULL
  );
  
  
  CREATE TABLE [dbo].[PB_Player] (
      [Id]             UNIQUEIDENTIFIER NOT NULL,
      [UniquePlayerId] NCHAR (32)       NOT NULL,
      [Name]           NVARCHAR (50)    NOT NULL,
      [DateCreated]    DATETIME         NOT NULL
  );
  </code></pre>
  
  <p>The idea is of course to only have each player once in the database and let them have multiple hiscore entries. This table PB_HiscoreEntry will have a lot of scores, but by doing a simple OrderBy descending, I can create a real hiscore list where the one with highest score is at the top and the lowest at the bottom.
  My problem here is that my database don't have any idea of the actual Rank of the score compared to the others. This is something I should do as I do the OrderBy query described above.</p>
  
  <p>Here is some code to help illutrate what I want to archive:</p>
  
  <pre><code>var q = (
      from he in entities.PB_HiscoreEntry
      orderby he.Score descending
      select new HiscoreItem()
      {
          UserId = he.PB_Player.UniquePlayerId,
          Username = he.PB_Player.Name,
          Score = he.Score,
          //Put in the rank, relative to the other entires here
          Rank = 1 
      });
  </code></pre>
  
  <p>HiscoreItem, is just my own DTO i need to send over the wire.</p>
  
  <p>So anybody have an idea of how I can do this or am I on a totally wrong path here?</p>