CatchingMonkey
CatchingMonkey

Reputation: 1391

Linq Using Contains On An Array

Im trying to query a datatable using linq, ideally what I would like to do is compare a column of strings to an array of strings, returning those that match.

Any ideas?

Cheers in advance

CM

Upvotes: 1

Views: 142

Answers (2)

Jeff Ogata
Jeff Ogata

Reputation: 57783

You need to use one of the Field<T> methods of DataRowExtensions.

var foo = from r in dt.AsEnumerable()
          where bar.Contains(r.Field<string>("barColumn"))
          select r;

Upvotes: 3

Saeed Amiri
Saeed Amiri

Reputation: 22555

myDB.Where(x=> array.Contains(x));

Upvotes: 1

Related Questions