I have a list:
List<Dev> devices= new List<Dev>(){
new Dev{ Add="5",Name="A" },
new Dev{ Add="5",Name="a" },
new Dev{ Add="9",Name="b" },
new Dev{ Add="6",Name="c" },
new Dev{ Add="9",Name="b" },
};
I want to write a Linq "Lambda Expression" which return the records that are not duplicates and also the first record from duplicates based on "Name" in the list. Also ignore case while finding duplicates
Expected Output:
Add=5, Name=A
Add=9, Name=b
Add=6, Name=c
Query what I have now (It returns the "Name" which is duplicate):
results.GroupBy(x => x.Name, StringComparer.OrdinalIgnoreCase)
.Where(g => g.Count() > 1)
.Select(g => g.Key)
.ToList();