is it posible to use operators with _context

good afternoon,
I was wondering if it is posible to use operators like OR/AND as follow in asp.net

 if (_context.User.Any(ac => ac.Id.Equals(23) && ac.Active.Equals(1)))

Open in new window


or what is the right way of doing something similar to that.

I appreciate your help thanks.
LVL 1
StevenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

louisfrCommented:
I think User is not an IEnumerable. You cannot use the method Any on it.
0
StevenAuthor Commented:
Maybe I should've written what I was trying to accomplish, I'm trying to check if a specific user is active.
thanks
0
louisfrCommented:
My last comment was just a thought I had when reading your code and I forgot to actually answer the question.
You can use boolean operators in asp.net. Are you getting an error when you use them?
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

StevenAuthor Commented:
Im new to MVC, so im not sure if what I was doing was posible, this is the error I get System.ArgumentException: 'DbComparisonExpression requires arguments with comparable types.'
0
Snarf0001Commented:
If it's typical code, I'm assuming "Active" on the database is actually a bit flag.  In which case even though it's 0 or 1 on the db, it maps to true / false as a bool on the data context.

if (_context.User.Any(ac => ac.Id == 23 && ac.Active == true))

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
louisfrCommented:
Most probable cause of the problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.