I have a project that is using Entity framework and AspNet Identity.
One of the parameters of the IdentityUser is a deactivated field.
Within the app, if I wanted to get the users, I would do this:
var users = Context.Users //etc....
However, I do not want this query to return any deactivated users. I know I could do this
var users = Context.Users.Where(x => x.Deactivated != true);
However, I am reluctant to do this, as I am sure that in time someone will forget to add this where clause.
Is there a way for entity to do this automatically to all context queries? I have found this:
https://learn.microsoft.com/en-us/ef/core/querying/filters
But I do not have EF core and cannot upgrade to it.
I know I could make a wrapper function and call this, but I am trying to find a better solution...