I want to get students who fulfill the following criteria in a WPF application-
- Are "passed" the examination
- Except first "passed" student in each "group" (Example: Group 1 & 3)
- If a group contains only one "passed" student, that student should be omitted (Example: Group 2)
- Original grouping should be preserved
Please refer this Students collection as I don't find any option to create tables in StackOverflow.
Code I tried-
var results = myList
.GroupBy(x => x.GroupID)
.Select(g => g.OrderBy(x => x.Status)
.Where(g => g.Status == "Passed")
.Skip(1)
.ToList();
The Problem: This doesn't omit the first "passed" student in each group. Instead, it omits only "Richard" (in Group 1) in the entire collection.
)- opened here.Select(and never closed