I am trying to find the number of items in a list that differ in a property which itself is a list. I found this example using Linq here:
List<Person> distinctPeople = allPeople
  .GroupBy(p => p.PersonId)
  .Select(g => g.First())
  .ToList();
This works nicely if the property PersonId is scalar. But in my case this does not work and in the following the items in SelectedTargets are always returned as distinct even though the ListOfActions is equal in all items:
List<Target> distinctTargets = SelectedTargets.GroupBy(p => p.ListOfActions).Select(g => g.First()).ToList();
If instead I pick the first item in ListOfActions it works:
List<Target> distinctTargets = SelectedTargets.GroupBy(p => p.ListOfActions[0]).Select(g => g.First()).ToList();
So how can I check for equality of the whole list ListOfActions? (it doesn't necessarily have to user Linq)
The definition of SelectedTargets is:
List<Target> SelectedTargets = new List<Target>();
and is DispensingActionList:
private DispensingActionList ListOfActions = new DispensingActionList();
public class DispensingActionList : List<DispensingAction>
    { ...
 
     
     
    