Reputation: 971
I have a
List<PublicGrouping<DateTime,Event>>
used in a LongListSelector for a windows phone 7 project. PublicGrouping implements IGrouping.
How can I get a List of PublicGrouping where Event.X = Y?
Upvotes: 1
Views: 420
Reputation: 887757
You're trying to find all groups Where
Any
of the Events in the group meet a condition:
var yGroups = list.Where(g => g.Any(e => e.X == y));
EDIT:
You're trying to Select
new groups from the Events in the old Groups Where
some condition, and you only want non-empty groups:
var yGroups = list.Select(g => new PublicGrouping(g.Key, g.Where(e => e.X == y))
.Where(g => g.Any());
Upvotes: 3