Filtering, Ordering (Sorting) and Pagination library for .Net Core, ASP.NET Core, C#
For .Net Core developers, Fop serves you quite simple, easy to integrate and extensible Filtering, Ordering (Sorting) and Paging functionality.
To see detailed documentation please visit wiki page
Let's see how easy to use Fop
Fop
NuGet package from here.PM> Install-Package Fop
[HttpGet]
public async Task<IActionResult> Index([FromQuery] FopQuery request)
{
var fopRequest = FopExpressionBuilder<Student>.Build(request.Filter, request.Order, request.PageNumber, request.PageSize);
var (filteredStudents, totalCount) = await _studentRepository.RetrieveStudents(fopRequest);
return Ok(filteredStudents);
}
public async Task<(List<Student>, int)> RetrieveStudents(IFopRequest request)
{
var (filteredStudents, totalCount) = _context.Students.ApplyFop(request);
return (await filteredStudents.ToListAsync(), totalCount);
}
Install Fop, Build your object by using FopExpressionBuilder<Student>.Build() then ApplyFop() That's All 🤘
More and more detail at here and in Wiki page. Please visit before you decided to not use
Supported operators for type are below;
Fop uses these query sign for preparing expression.
Operators | Query Sign | Int/Long/Decimal/Double | String | Char | DateTime | Guid |
---|---|---|---|---|---|---|
Equal | == |
✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
NotEqual | != |
✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
GreaterThan | > |
✔️ | ❌ | ❌ | ✔️ | ❌ |
GreaterOrEqualThan | >= |
✔️ | ❌ | ❌ | ✔️ | ❌ |
LessThan | < |
✔️ | ❌ | ❌ | ✔️ | ❌ |
LessOrEqualThan | <= |
✔️ | ❌ | ❌ | ✔️ | ❌ |
Contains | ~= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
NotContains | !~= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
StartsWith | _= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
NotStartsWith | !_= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
EndsWith | |= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
NotEndsWith | !|= |
✔️ | ✔️ | ❌ | ❌ | ❌ |
api/students/
?Filter=Midterm>10;and
&Order=Midterm;desc
&PageNumber=1
&PageSize=2`
The above expression returns us students whose midterms is more than 10, then order by Midterm descending with page number is 1 and page size is 2.
It works! 🚀 For more about query language click here!
It works! Perfect!
Works for multiple filter logic as well! 🎉
I don't want to make readme page so crowdy. please visit the wiki page to see more feature of the package
This project is licensed under the MIT License - see the LICENSE.md file for details
Everyone is welcome to contribute!