May 25, 2020 04:30 PM|wavemaster|LINK
Grouping and Sorting is not working as expected.
My dataset, for the conditions per OP:
1: apptDate May 24, calOId = 2
2: apptDate May 27, calOId = 1
3: apptDate May 24, calOid = 1
The intended result is:
1: ApptDate May 24:
1.1 calOId = 1
1.2 calOId = 2
2: ApptDate May 27:
2.1 calOId = 1
var visits1 = dbContext.ScheduledSvcVisits.Where(s => s.enteredByProviderId == providerId && (s.visitStatus == "Scheduled" || s.visitStatus == "Invited")).OrderBy(s => s.apptDate).ThenBy(s => s.calOId).GroupBy(s => s.apptDate);or
var test = from visit in visits orderby visit.apptDate orderby visit.calOId group visit by visit.apptDate into newGroup select newGroup;
I have since learned that OrderBy needs to go first and GroupBy last, and I have the two queries as per that approach
The squiggle is now gone.
The result (from visists1 or test) is still NOT as expected:
1.1 calOId = 2
1.2 calOId = 1
Not matter if I do ASC or DESC Linq equivalents calOId orderby is not working right, they need to be reversed!
I am missing something here, but what?