DynamicFilter.Component 1.0.0

dotnet add package DynamicFilter.Component --version 1.0.0
                    
NuGet\Install-Package DynamicFilter.Component -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicFilter.Component" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DynamicFilter.Component" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DynamicFilter.Component" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DynamicFilter.Component --version 1.0.0
                    
#r "nuget: DynamicFilter.Component, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DynamicFilter.Component@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DynamicFilter.Component&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DynamicFilter.Component&version=1.0.0
                    
Install as a Cake Tool

DynamicFilter.Component

DynamicFilter is a lightweight and extensible .NET library for dynamically filtering and sorting entities in an Entity Framework Core DbContext based on string-based filter expressions. It's ideal for building flexible APIs where filter logic needs to be dynamic and runtime-driven.

Features

  • Filter any EF Core entity by name and a simple filter string
  • Supports nested property sorting (e.g., sortBy=Author.Name)
  • Automatically resolves entities via DbContext metadata
  • Easily extensible for additional filter logic
  • Minimal setup via IServiceCollection extension

Usage

Install via NuGet Package Manager:

dotnet add package DynamicFilter.Component
  1. Register the Service

Add the following in your Program.cs or wherever you configure services:

builder.Services.AddDynamicFilter();
  1. Inject and Use the Filter Service
public class MyController : ControllerBase
{
    private readonly IDynamicFilterService<MyDbContext> _filterService;

    public MyController(IDynamicFilterService<MyDbContext> filterService)
    {
        _filterService = filterService;
    }

    [HttpGet("filter")]
    public async Task<IActionResult> Filter(string filter, string entityName)
    {
        var results = await _filterService.FilterEntitiesAsync(filter, entityName);
        return Ok(results);
    }
}

Filter Syntax

The filter string is a comma-separated list of key-value pairs. Supported keys:

  • [propertyName]=[value] — Basic filtering by property
  • sortby=[PropertyName] — Sort by the specified property (supports nested properties)

Example

Example 1: name=John,age=30,sortby=CreatedDate,sortdescending=true
Example 2: category=Electronics, isinstock=true, sortby=price for Product entity
Example 3: category=Electronics, isinstock=true, sortby=price, maxprice=550 for Product 
Example 4: sortby=price, maxprice=550, minprice=222 for Product
Example 5: sortby=price, maxprice=550, minprice=222, price=333 (hard equality is  ignoring) for Product
Example 6: sortby=price, maxprice=550, price=220 (hard equality is  ignoring) for Product
Example 7: Roles.Name=Admin, sortby=CreatedDate
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 70 7/18/2025