In the world of modern web applications, efficiently managing large datasets is a key challenge. Users expect lightning-fast searching, sorting, and paging, whether they are browsing a product list or system logs. Developers often face a difficult choice: write repetitive filtering code manually—which is tedious and error-prone—or use heavy frameworks that can negatively impact performance.
This is where Gridify comes in—a modern, lightweight, and incredibly fast library for the .NET ecosystem that transforms complex data operations into simple, readable queries.
What exactly is Gridify?
Gridify is a paged-filtering engine library that allows you to map strings (originating from URL parameters, for example) directly into LINQ queries. It works natively with IQueryable, meaning it integrates seamlessly with Entity Framework Core, AutoMapper, or pure in-memory collections.
The primary goal of Gridify is to eliminate boilerplate code. Instead of writing dozens of if statements to check if a user wants to sort by date or filter by name, you simply pass a single configuration object.
Why choose it?
- Performance: Gridify is optimized for high speed and low memory footprint.
- Ease of Use: Web API integration often boils down to just one line of code.
- Security: The library includes built-in mapping mechanisms (
GridifyMapper) that protect against Mass Assignment attacks—users can only filter by the specific fields you allow. - Flexibility: It supports complex logical operators (AND, OR), parentheses, and nested property filtering (filtering by relationships).
Basic Usage Example
Imagine we are building an API for an online store. Instead of building filtering logic from scratch, simply install the NuGet package:
dotnet add package Gridify
Then, in your controller, you can use the Gridify extension method:
[HttpGet]
public ActionResult<PagingDto<Product>> GetProducts([FromQuery] GridifyQuery query)
{
// Gridify automatically parses the query string and applies filters to the database
var data = _context.Products.Gridify(query);
return Ok(data);
}
With this setup, a user can send a URL request like this: GET /products?filter=price>100,category=electronics&sort=name&page=1&pageSize=20
GridifyMapper – Full Control
One of Gridify’s strongest features is the GridifyMapper. It allows you to define aliases for database fields. For instance, if your database column is named First_Name_In_Database, you can expose it to the user as the simple key name.
Summary
Gridify is an excellent choice for .NET developers who value the DRY (Don’t Repeat Yourself) principle and want to deliver advanced filtering features in record time. It is a tool that perfectly bridges the gap between simple lists and complex reporting solutions.