-1

How to convert this request to Linq to get a date and a row number from table?

SELECT ROW_NUMBER() OVER (ORDER BY Date) AS Row, 
       Date, 
       WebUrlReferer
 FROM [Cnx].[dbo].[Action]
Eugene Lisitsky
  • 12,113
  • 5
  • 38
  • 59
  • 2
    see this http://stackoverflow.com/questions/9980568/row-number-over-partition-by-xxx-in-linq – A_Sk Dec 22 '16 at 11:18
  • 1
    Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) And the perfect question And how to create a [Minimal, Complete and Verifiable example](http://stackoverflow.com/help/mcve) SO is not a free Coding or Code Conversion or Debugging or Tutorial or Library Finding service Here at SO we fix your attempts, we do not code things for you – Mingebag Dec 22 '16 at 12:19

1 Answers1

1
var query = youContext.Action
            .Select((x, i) => new
                              {
                                  Row = i,
                                  Date = x.Date,
                                  WebUrlReferer = x.WebUrlReferer
                              }) 
            .OrderBy(x => x.Date);
Nikita
  • 88
  • 4