Following is the same implementation for SQL distinct in LINQ
var distinctItems = items
.GroupBy(x => x.PropertyToCompare)
.Select(x => x.First());
http://blog.jordanterrell.com/post/LINQ-Distinct()-does-not-work-as-expected.aspx
HOW TO GET DISTINCT VALUES FROM THE LIST<T> WITH LINQ
HOW TO GET DISTINCT VALUES FROM THE LIST<T> WITH LINQ
No comments:
Post a Comment