Does Entity Framework provide a way to use in
as a where
condition?
I'd like to use LINQ if possible to generate a query equivalent to:
select * from dbo.Strains where Name in ('A', 'B', 'C', … )
var result = context.Strains
.Where(s => new[] { "A", "B", "C" }.Contains(s.Name));
Entity Framework is smart enough to translate this into the appropriate SQL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.