class Entity{ public int Id { get; set; } public int Priority { get; set; } }
And also you have some sequence of Entity objects (i.e. IEnumerable
As far as "and" is commutative and according to the task the following two blocks of code should return the same result
var group1 = entities.Where(e=>e.Priority > 5).GroupBy(e=>e.Id);and
var group2 = entities.GroupBy(e=>e.Id).Select(g=>g.Where(e=>e.Priority > 5));
But this is wrong. There are two different sets of input data that will produce to different results (by two different reasons). Could you find them out?