Lambda Expression To Select a distinct set of objects


/ Published in: C#
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. myObject.GroupBy(c => c.Id).Select(grp => grp.First());

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.