I have a list of dates. I would like to query the list and return a list of pairs where the first element is the date and the second is the date that occurs immediately before the first date (in the list).
I know that this can be easily achieved by sorting the list and getting the corresponding dates by index, I am curious how this can be achieved in LINQ.
I did this in SQL with the following query:
SELECT Date, (SELECT MAX(Date) FROM Table AS t2 WHERE t2.Date < t1.Date) AS PrevDate FROM Table AS t1
source share