Distinct objects & distinct based on a specific propertie (in this case Mobile and Fax) by LINQ
//distinct objects
List<objects> listObjects = (from obj in db.Objects
select obj).Distinct().ToList();
//distinct based on a specific propertie (in this case Mobile and Fax)
List<Objects> listObjects = (from obj in db.Objects
select obj).GroupBy(n => new {n.Mobile, n.Fax})
.Select(g => g.FirstOrDefault())
.ToList();
Comments
Post a Comment