File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ JsonApiDotnetCore provides a framework for building [json:api](http://jsonapi.or
2424 - [Defining Custom Data Access Methods](#defining-custom-data-access-methods)
2525 - [Pagination](#pagination)
2626 - [Filtering](#filtering)
27+ - [Custom Filters](#custom-filters)
2728 - [Sorting](#sorting)
2829 - [Meta](#meta)
2930 - [Client Generated Ids](#client-generated-ids)
@@ -317,6 +318,31 @@ identifier):
317318?filter[attribute]=like:value
318319```
319320
321+ #### Custom Filters
322+
323+ You can customize the filter implementation by overriding the method in the ` DefaultEntityRepository ` like so:
324+
325+ ``` csharp
326+ public class MyEntityRepository : DefaultEntityRepository <MyEntity >
327+ {
328+ public MyEntityRepository (
329+ AppDbContext context ,
330+ ILoggerFactory loggerFactory ,
331+ IJsonApiContext jsonApiContext )
332+ : base (context , loggerFactory , jsonApiContext )
333+ { }
334+
335+ public override IQueryable <TEntity > Filter (IQueryable <TEntity > entities , FilterQuery filterQuery )
336+ {
337+ // use the base filtering method
338+ entities = base .Filter (entities , filterQuery );
339+
340+ // implement custom method
341+ return ApplyMyCustomFilter (entities , filterQuery );
342+ }
343+ }
344+ ```
345+
320346### Sorting
321347
322348Resources can be sorted by an attribute:
You can’t perform that action at this time.
0 commit comments