Search code examples
linqlinq-to-entities

How to do a "where in values" in LINQ-to-Entities 3.5


Does anybody know how to apply a "where in values" type condition using LINQ-to-Entities? I've tried the following but it doesn't work:

var values = new[] { "String1", "String2" };  // some string values

var foo = model.entitySet.Where(e => values.Contains(e.Name));

I believe this works in LINQ-to-SQL though? Any thoughts?


Solution

  • It is somewhat of a shame that Contains is not supported in Linq to Entities.

    IN and JOIN are not the same operator (Filtering by IN never changes the cardinality of the query).