In statement for LINQ to objects
问题 Is there an equivalent of a SQL IN statement in LINQ to objects? 回答1: Yes - Contains. var desiredNames = new[] { "Jon", "Marc" }; var people = new[] { new { FirstName="Jon", Surname="Skeet" }, new { FirstName="Marc", Surname="Gravell" }, new { FirstName="Jeff", Surname="Atwood" } }; var matches = people.Where(person => desiredNames.Contains(person.FirstName)); foreach (var person in matches) { Console.WriteLine(person); } (In LINQ to SQL this ends up as an "IN" query.) Note that in LINQ to