I have an entity called Client on my .edmx file.
I have to run several linq querys agains it but on all of them, i need a filter (lets say active=1).
I dont want to have a where c.active == 1 on all my queries, it makes more sense that my entity has a default filter applied. Is it something that can be done?
Or maybe can I have a query as base to an entity instead of a table? (I’m on a database first approach)
I know another solution would be to create a view on the DB and link the entity to the view, but I don’t want that either.
You may add additional method to your generated Database context:
And use it throughout your code. As it’s part of partial class (defined in some other file than your generated context class), it’s not affected by codegen tool when you refresh your schema.