Say you had a table in SQL and you wanted to find all the rows where a particular column could be one of 3 options. You could write something like this:
SELECT * FROM MyTable WHERE uid IN (123, 456, 789)
That's effectively what I want to do with a
DataTable in VB. I saw this post: Query rows that the datatable field contain any item in the list<string>
Which seemed to be exactly what I wanted, but it's not working as I expected it to. I basically just used a C# -> VB converter and plugged in my variables and came up with this:
Dim item = From a In dtCodes.AsEnumerable() Where lstCodes.Any(Function(x) a.Field(Of String) ("Code").ToUpper().Contains(x.ToUpper())) Select a
dtCodes is a DataTable with a column
Codes in it.
lstCodes is a
List(Of String) with some values in it.
item just has all of the rows from
dtCodes though, regardless of whether or not their
Code column value exists in
What am I missing?
edit; Note that I don't have to use LINQ, if there's an easier or better way.