Filter dt with LINQ

Hello everyone. I’m doing filtering with linq. I have a dt1 that looks for a value in a dt2, if the dt2 contains the value, it deletes it and keeps the ones it doesn’t contain in a dt3. The query looks like this

This way works:

(From r In dt1.select()
Where dt2.select(“[ColumnName”]=‘" + r(“ColunName”).tostring+"’"
).count=0
Select r).CopytoDataTable

But instead “=” i need .contains
(From r In dt1.select()
Where dt2.select(“[ColumnName”]Like%‘" + r(“ColunName”).tostring+"%’ "
).count=0
Select r).CopytoDataTable (Doesnt work)

Filtering with LINQ Operator:

Filtering with the Select Method:

with filter syntax:

we suggest first to decide what is focused (LINQ or Select Method)

Maybe you can rewrite to

dt3 =

(From d in dt1.AsEnumerable()
Let vc = d("ColName").toString.ToUpper
Let chk = dt2.AsEnumerable.Any(Function (d2) d2("ColName").toString.ToUpper.Contains(vc))
Where Not chk
Select r =d).CopytoDataTable

Handling empty results:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.