I need something like this: Select name from users where id = 1 or id = 2.
I know I can do this:
_db.Users
.Where(u => u.Id == 1 || u.Id == 2);
But is there any alternative to this?
Is there something like this:
_db.User
.Where(u => u.Id == 1)
.Or
.Where(u => u.Id == 2)
Not directly. Remember,
_db.Users.Where(u => u.Id == 1)is the user whose id is 1. You cannot get the user with id 2 from that, because it isn’t there.You can use some other approach, such as
or
though.