Reputation: 2078
Let's say I have a table containing reports, and each report has an Employee ID for the employee assigned to it.
Let's also say I have a list of employee ID, like:
[ "1001", "1002", "1003", "1004", "1005", "1006", "1007"]
What LINQ query will return all the reports that have those employee IDs? If it were just a single criteria (like if I wanted everything older than a year), I could just do
query.Where(report => report.LaunchedDate < lastYear)
But how do I do it for when I have many items? Do I need to use a loop or is there a LINQ method for enumerating the list of employee IDs?
Upvotes: 1
Views: 78
Reputation: 6441
Sounds like you are looking for something along the lines of:
var employeeIds = ["1001", "1002", "1003", "1004", "1005", "1006", "1007"];
query.Where(report => employeeIds.Contains(report.EmployeeId));
Upvotes: 5