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());


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.