Return to Snippet

Revision: 63125
at April 10, 2013 07:32 by kwhite1975


Initial Code
myObject.GroupBy(c => c.Id).Select(grp => grp.First());

Initial URL
http://stackoverflow.com/questions/1300088/distinct-with-lambda

Initial Description
This line of code allows you to group a set of objects by a field and then get the first item in that group.  This allows you to do a distinct by a specific property.

Initial Title
Lambda Expression To Select a distinct set of objects

Initial Tags

                                

Initial Language
C#