Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to batch configure global filters on soft deleted entities and non-soft deleted entities #35145

Open
ByZhouhang opened this issue Nov 19, 2024 · 1 comment

Comments

@ByZhouhang
Copy link

The official document Global Query Filters link is as follows:

https://learn.microsoft.com/en-us/ef/core/querying/filters#accessing-entity-with-query-filter-using-required-navigation

When I configure global filtering on an entity, it is officially recommended The corresponding navigation entity must also be configured again, written as follows:

modelBuilder.Entity<Blog>().HasQueryFilter(b => b.Url.Contains("fish"));
modelBuilder.Entity<Post>().HasQueryFilter(p => p.Blog.Url.Contains("fish"));

Some entities in my project use soft deletion, but there is a one-to-one or one-to-many relationship between the soft-deleted entities and many other entities that are not soft-deleted. If you follow the configuration method of the document, it would be too much to configure them one by one. It’s troublesome and easy to miss. Is there a way to configure it in batches?

@cincuranet
Copy link
Contributor

There's no in-the-box way to configure in batches. On the other hand, it shouldn't be that difficult to build some infrastructure yourself with little bit of reflection and some attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants