1

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',  … )
1

1 Answer 1

3
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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.