I’m starting to love Lambda expressions but I’m struggling to pass this wall:
public class CompanyWithEmployees { public CompanyWithEmployees() { } public Company CompanyInfo { get; set; } public List<Person> Employees { get; set; } }
My search:
List<CompanyWithEmployees> companiesWithEmployees = ws.GetCompaniesWithEmployees(); CompanyWithEmployees ces = companiesWithEmployees .Find(x => x.Employees .Find(y => y.PersonID == person.PersonID));
So, I want to get the Object ‘CompanyWithEmployees’ that have that Person (Employee) that I’m looking for, but I’m getting ‘Cannot implicit convert ‘Person’ To ‘bool’)‘ which is correct, but if I’m not passing the Person object, how can the first Find executes?
Because you want to check for existance, perhaps try:
This will check for any
Personwith the sameParID; if you mean the samePersoninstance (reference), thenContainsshould suffice: