I’m trying to use .Any() in an if statement like so:
if(this.db.Users.Any(x => x.UserID == UserID)){
// do stuff
}
Is there a way I can put multiple conditions inside of the .Any()? For example something like:
if(this.db.Users.Any(x => x.UserID == UserID AND x.UserName == UserName)){
// do stuff
}
Or is there a better way to go about this?
Sure, use the
&&operator.If you can use it in an
ifstatement, you can use it here. The lambda needs to evaluate to a bool.