Skip to content

Filtering, Ordering (Sorting) and Pagination library for .Net Core, ASP.NET Core, C#

License

Notifications You must be signed in to change notification settings

arslanaybars/Fop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fop

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.

Fop Nuget

To see detailed documentation please visit wiki page

Quick Start

Let's see how easy to use Fop

  1. Install Fop NuGet package from here.
PM> Install-Package Fop
  1. Add FopQuery to your get method
[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);
}
  1. ApplyFop from your repository
 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.Build() then ApplyFop() That's All 🤘

More and more detail at here and in Wiki page. Please visit before you decided to not use

Deep Dive

Fop Operators

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 !|= ✔️ ✔️
Example

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!

Examples

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

Next Things..

  • LOGO
  • Better unit tests
  • Improved sample

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Contributing

Everyone is welcome to contribute!

Acknowledgments

  • DynamicExpresso It helps me to save my hair pulled down! 🙏 Thanks for the great library. It helps me a lot on Filtering.