Multiple "where" conditions in Entity Framework 4 statements - Possible?

c#, entity-framework, linq

Solution

You can use `List.Contains`:

List<string> yourList = ...;
var query = context.YourTable.Where(x => yourList.Contains(x.Foo));

Problem

I have a funny feeling I'm approaching this problem wrongly. Here's what I'm trying to do: I have a list of strings (`List<string>`) and I want to return all the rows from a table where a particular field in that row matches one of the strings in the list. This is simple if I use a loop and execute one Linq statement per string. Of course, I want to avoid as many round-trips to the database as possible. What sort of strategy would you recommend here? I'm comfortable using LINQ together with Entity Framework but I realise I might be limited by these particular technologies. I'm using Entity Framework 4.

Original source