Summarizing the task in one line for clarity, as suggested:
I want to find all things that have different values for any field and less than a week (based on another field)
Let's say I have a Users table and a User class.
Each User has the following fields:
SignUpDate field with non-zero DateTimeUserType field int, for this question let's say that it is either 1 or 0
I would like to select all pairs of users who have signed up for less than 7 days and have a different type of user.
My current (pathetic) attempt included OrderBy(r=>r.SignUpDate) and .ToList , which was not a big deal, as the number of users for every 2 weeks is small. (I grabbed all the users from this with overlapping weeks and compared the data).
However, I believe that my current solution is pretty bad. I have no idea how to approach this.
I think the main problem is that I don’t know how to solve the "select every two matching records" task in LINQ for Entities after ordering.
Any help is greatly appreciated, I am interested in how I can solve such a problem without asking my question in the future.
Input example
SignUpDate UserType ------------------------------------ 2008-11-11 1 2008-11-12 0 2008-11-13 0 2008-12-13 0 2008-12-15 1
Output example
Any meaningful way to indicate that the problematic pairs are:
2008-11-11 1 2008-11-12 0
(Different day and different type)
AND
2008-12-13 0 2008-12-15 1
(two different days and different types)
Here is the related SQL solution that I found.