Let’s say that we want to select rows from
Products table in Northwind database where ProductId matches 3, 7, 8,
10. Our query should include the Where IN clause. Something like this:
SELECT *
FROM Products
WHERE ProductID in (3, 7, 8, 10)
Of course Select * is not a good way to write any Query but this is
just to convey a point. LINQ query which will work with integers and
give me a Where IN looks like this:
List<int> productIds = new List<int> { 3, 7, 8, 10 };
using (NorthwindDataContext context = new NorthwindDataContext())
{
var query = from p in context.Products
where productIds.Contains(p.ProductID)
select p;
}