Accepted answer

You can group items by the key, and then select what item from the group you want to use as value. I use FirstOrDefault as an example:

... .Select(c => new SampleClass { Id = c.Location.Name, Name = c.Location.Name })
    .GroupBy(c => c.Id)
    .Select(group => group.FirstOrDefault())


Is this what you need: ?

This is an extension for IEnumerable that allows you to .Distinct() for any field (or even several ones using lambdas), which creates IEqualityComparer for you on the fly.

Related Query

More Query from same tag