6

How to implement following query of SQL in entity framework. SELECT * FROM Users WHERE UserID in (1,2,3,4).

I am trying to do

var users = from e in context.Users where e.UserId in (list of user ids)

Thanks Ashwani

1

2 Answers 2

10
var users = from e in context.Users where idList.Contains(e.UserId)
Sign up to request clarification or add additional context in comments.

Comments

9

Try this:

var identifiers = new[] { 1, 2, 3, 4 };
var users = from e in context.Users where identifiers.Contains(e.UserId);

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.