0

as the title says, I'm trying to group a selection by it's distinct values, and then iterate through the result to populate a listView of checkboxes, my code is below

var checkBoxAdd =
            from sale in saleData
            orderby sale.City.ToList()
            group sale.City by sale.City.Distinct() into cityDistinct
            select cityDistinct;


foreach (House s in checkBoxAdd)
{
    listViewCities.Items.Add(s.City.ToString());
}

I am getting the following error:

enter image description here

Can anyone help me out with this please

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Rick D
  • 139
  • 1
  • 11

1 Answers1

0

That is happen because chekBoxAdd contains no House Objects. Your checkBoxAdd is a IEnumerable<IGrouping<IEnumerable<char>, string>>. You're trying to compare House object with IGrouping<IEnumerable<char>, string> element.