0
votes

I have this linq query in my controller and it is working fine,

var Engineers = dbcontext.Employees.Where(i => i.Department == "Engineers");

but I would like to add a second condition to the query to filter out the results,

var Engineers = dbcontext.Employees.Where(i => i.Department == "Engineers" && i.UserStatus = 1);

Thanks for your help.

1
That's how you do it. Except you want to use == to compare values instead of = (assignment operator). - nbokmans
Typo. You're trying to assign instead of compare. Use the == operator that you were already using previously. - David
Thanks nbokmans, can't believe I missed that. - ullevi83

1 Answers

1
votes

You made a typo, just need to use comparison operator (==) instead of assignation (=)

So it would be like that:

var Engineers = dbcontext.Employees.Where(i => i.Department == "Engineers" && i.UserStatus == 1);