I have a data collection of type IEnumerable<Objects.LabourHours>
containing labour records for various employees. I wish to filter the list and return only records for selected employees, which is specified by a list of int[] employees
containing the EmployeeID
s.
class LabourHours
{
public int ID {get;set;}
public int EmployeeID {get;set;}
public int HoursWorked {get;set;}
}
How would I go about this? I am sure this has been asked before but I can't find anything similar on here. The closest I have found involves grouping the records by UserID, which is not what I need - I need the actual records.
You can filter your list with LINQ Where
using Contains
method:
var result = list.Where(x => employees.Contains(x.EmployeeID));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With