I’m trying to display those rows in my DataGrid, which share the same column-value.
For example, for Persons, who have the same Surname, I tried this:
dataGrid.ItemsSource = _dataContext.Addresses.GroupBy(a => a.SurName).Where(grp => grp.Count() > 1).Select(grp => grp.Key);
This works seemingly, as my WPF DataGrid contains rows after this command… Eventually it only displays empty rows, as no column is filled with a value.
Or I tried this with Persons, who have the same City:
dataGrid.ItemsSource = _dataContext.Addresses.GroupBy(a => a.City).Where(grp => grp.Count() > 1).Select(grp => grp.Key).Select(a => a);
Is there any proper way to do this?
You are only selecting the key in your example:
What I assume you are trying to do is to select the whole row:
To compare first and last names:
EDIT: For L2E, you can (I think) use anonymous types:
The above could be incorrect- not 100% sure.