Linq Query- Discard all the data table rows matching with the items in the list

I have list which have the values {1,2,3,4,5} and I have a data table as below.

image

I want to discard the rows if the list items is equal to Number column rows.

So the output will be as below.
image

I know, I can do it with filter data table and for each loop but I want to see if we can do it with linq query.

If you have any linq queries in your mind for this scenarios then please share.

Thanks,
Shreyash.

Hi,

How about the following?

dt = dt.AsEnumerable.Where(Function(r) not listVar.Contains(CInt(r("Number").ToString))).CopyToDataTable()

Sample20230405-4L.zip (8.3 KB)

Regards,

2 Likes