palak mehta
palak mehta

Reputation: 706

Filter the DataTable on the basis of array

I have a DataTable dtEmployee with one of the column is EmployeeId.

I have an array of Integers with. I have to find all the values of array , that are not there in EmployeeId column of DataTable dtEmployee.

Upvotes: 1

Views: 601

Answers (1)

Habib
Habib

Reputation: 223267

You can use Enumerable.Except

List<int> empIds = new List<int>(); //your employee Ids List

List<int> resultList = empIds.Except(dtEmployee .AsEnumerable()
                                       .Select(r => r.Field<int>("EmployeeID"))
                                       .ToList()).ToList();

Upvotes: 5

Related Questions