score:1

Accepted answer
var custlist = new hashset<string>() { "a", "b", "c"...};

from record in table.toenumerable()
where custlist.contains(record.field<string>("customerid"))

score:0

var custlist = new hashset<int> { 10, 15, 17 };
customerset.where(c => custlist.contains(c.customerid));

score:2

in linq you use the contains() method to perform these kind of queries.

i don't know linq to datasets, but in linq to sql you can do the following:

var statuses = new int[] {1, 2, 3};

var query = from p in datacontext.products
            where statuses.contains(p.id)
            select p;

this should generate sql similar to:

select * from product p
where p.id in (1, 2, 3)

(note how it feels back-to-front in the linq code to the generated sql - that's why if you know sql well it's not very intuitive, but it makes very elegant use of existing .net language features)

this also typically works for string and collections of some other basic types that l2s knows about because they're in the framework.


Related Query