AutoFilterer Generators
AutoFilterer.Generators aims to generate filter objects from entities automatically via using dotnet source generators.
WARNING: This feature is beta for now and might will have braking changes in future.
Usage
Install AutoFilterer.Generators from NuGet.
Find your Entity you want to create auto filter object for.
Add
[GenerateAutoFilter]
attribute over it:You'll see
BookFilter
objects exists in your project. It's ready to use. Can be directly used as query parameter:In the decleration, BookFilter source code looks like:
Features
Generators tries to create best filter object that fit your requirements.
- So it uses a couple of mappings:
- Numeric properties will be created as
Range<T>
- String properties will be created as
string
with[ToLowerContains]
attribute - DateTime properties will be created as
Range<DateTime>
- Complex Types aren't supported yet.
- Numeric properties will be created as
Namespace
Namespace can be customized with attribute parameter.
Extensibility
All generated classes are partial and have virtual members. So you have 2 option to extend class:
Partial Class: A partial class can be created with same name in same namespace. So you can add more members in it.
Inheritance: Custom filter classes can added which inherits from Auto Generated types to override members.