I try to make a select from a datatable but I have errors.
First, I create a List of String and try to use Contains operator:
dtInJobData.AsEnumerable.Where(Function( r) (r(“ID”).toString<>“” And r(“Etat”).toString.Contains(listNotInSQL)).CopyToDataTable
with
variable: listNotInSQL
variable type: List < String >
and Default Value: New List(Of String)(New String(){“Terminé”,“En attente”})
but I always have the message Assign: The source contains no DataRows, and it’s not correct.
Secondly, I try to use !Contains operator:
dtInJobData.AsEnumerable.Where(Function( r) (r(“ID”).toString<>“” And !r(“Etat”).toString.Contains(listNotInSQL)).CopyToDataTable
with the same List
and I don’t understand the error message: Leading ‘.’ or ‘!’ can only appear inside a ‘With’ statement
instead of ! symbol mention as NOT
the expression be like this dtInJobData.AsEnumerable.Where(Function( r) NOT r(“ID”).toString.Equals(String.Empty) And NOT listNotInSQL.Contains(r(“Etat”).ToString)).CopyToDataTable
You are close to solution. Just confirm my understanding:
You want to check if a particular column value is not null or empty and is a containee of your listNotInSQL string list, right?
So give a try on:
dtInJobData.AsEnumerable.Where(Function( r)
not String.IsNullOrEmpty(r(“ID”).toString) And listNotInSQL.Contains(r(“Etat”).toString)).CopyToDataTable