I have two lists of objects
PersonResult. Both are linked through the property
PersonId. I need to create a filter for the list of
PersonResult that meet certain criteria for the
Person.Gender == "female").
Im currently using the following LINQ query to achieve this:
PersonResultList = PersonResultList.Where(pr => PersonList.FirstOrDefault(p => pr.PersonId == p.PersonId) != null && PersonList.FirstOrDefault(p => pr.PersonId == p.PersonId).Gender == "female");
This works apparently well, however, I must iterate twice through PersonList to check if the person exist and its gender. Is there a more elegant way to achieve this?