Open bittola opened 1 week ago
@dotnet-policy-service agree
will anybody review this? @roji , @ajcvickers
@bittola apologies, but the team is currently still very busy dealing with the 9.0 release that came out recently - we'll hopefully be able to get some time and review soon.
[x] I've read the guidelines for contributing and seen the walkthrough
[x] The code builds and tests pass locally (also verified by our automated build checks)
[x] Tests for the changes have been added (for bug fixes / features)
[x] Code follows the same patterns and style as existing code in this repo
Closes #8576
This PR adds support for defining multiple named global query filters on an entity. It follows pattern used for keyed services in ASP.NET Core dependency injection. It's backward compatible with the existing implementation where only single unnamed filter was possible.
Examples:
The example above shows the basic usage of the feature. As you can see we can use a value of any type as a filter key. In our example it was string and enum values. If the filter key is not defined as it is in
HasQueryFilter(x => !_ids.Contains(x.Id))
, string.Empty is used under the hood. It can be later used to disable that anonymous filter.This example shows how to ignore specific query filters by using their keys. To simplify the use we can use an overload allowing us to specify filters keys as params array. Sequential use of the method adds new keys to the ignored list. Note, that the string.Empty key disables the anonymous filter from the previous example.
If we want to ignore all filters at once we can do it be calling
IgnoreQueryFilters
overload with no parameters: