I have two List of objects like this:
List<EmployeeInfo> emp = getEmployees();
List<EmailList> emailist = getMasterList();
I want to get all the employees email address, firstname, lastName that exists in emailList, but do not exists in emp list. In other words, I want to exclude the email address of the users that exists in emp list. I wrote below LINQ to achieve this:
List<EmployeeInfo> result = emp
.Where(w => !emailist.Contains(w.EmailAddress))
.ToList();
above keeps giving me an error saying "cannot convert from string to emailList.
This is the model for both employeeInfo and emailList
public partial class EmployeeInfo
{
public int EmployeeInfoId { get; set; }
public DateTime DateFormFilled { get; set; }
public string EmployeeNumber { get; set; } = null!;
public string LastName { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string? MiddleName { get; set; }
public string EmailAddress { get; set; } = null!;
}
public partial class EmailList {
public string? LastName { get; set; }
public string? FirstName { get; set; }
public string? Eid { get; set; }
public string? Email { get; set; }
public DateTime LoadDate { get; set; }
}
any help will be appreciated.