An expansion on the question asked here, I am trying to do the same functionality, namely
IEnumerable<Customer> filteredList = originalList
.GroupBy(customer => customer.CustomerId)
.Select(group => group.First());
which in the comments, it was implied that this will not work if it is Linq to Entities and certainly isn't working for me, I get a null result set.
Doesn't work for me ! Even I tried 'FirstOrDefault' it didn't work. – JatSing Sep 25 '11 at 13:55
@JatSing: You must be using Linq to Entities. – Josh Mouch Feb 14 '12 at 14:45
So if the above doesn't work for Linq to Entities, how would I go about grouping an IEnumerable of an EntityType message set by two columns, and then get the first row of each group?