TranMinhSang.DynamicQueryExtension.EntityFrameworkCore 0.1.1

dotnet add package TranMinhSang.DynamicQueryExtension.EntityFrameworkCore --version 0.1.1
                    
NuGet\Install-Package TranMinhSang.DynamicQueryExtension.EntityFrameworkCore -Version 0.1.1
                    
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="TranMinhSang.DynamicQueryExtension.EntityFrameworkCore" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TranMinhSang.DynamicQueryExtension.EntityFrameworkCore" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="TranMinhSang.DynamicQueryExtension.EntityFrameworkCore" />
                    
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 TranMinhSang.DynamicQueryExtension.EntityFrameworkCore --version 0.1.1
                    
#r "nuget: TranMinhSang.DynamicQueryExtension.EntityFrameworkCore, 0.1.1"
                    
#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 TranMinhSang.DynamicQueryExtension.EntityFrameworkCore@0.1.1
                    
#: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=TranMinhSang.DynamicQueryExtension.EntityFrameworkCore&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=TranMinhSang.DynamicQueryExtension.EntityFrameworkCore&version=0.1.1
                    
Install as a Cake Tool

Dynamic Query Extension

Support

  • Search
  • Sort
  • Filter with LHS Bracket syntax
  • Pagination with offset pagination and Cursor Pagination

How to use

The First parameter is the key word The Second one is The Specific fields that You wanna search The Third is how deep this could search


dbContext.User
    .Search("rose",["name"], 1)
    .ToListAsync();

Filter

To do filter in this template, we use LHS Brackets.

LHS is the way to encode operators is the use of square brackets [] on the key name.

For example

GET api/v1/users?filter[dayOfBirth][$gt]="1990-10-01"

This example indicates filtering out users whose birthdays are after 1990/10/01

All support operations:

Operator Description
$eq Equal
$eqi Equal (case-insensitive)
$ne Not equal
$nei Not equal (case-insensitive)
$in Included in an array
$notin Not included in an array
$lt Less than
$lte Less than or equal to
$gt Greater than
$gte Greater than or equal to
$between Is between
$notcontains Does not contain
$notcontainsi Does not contain (case-insensitive)
$contains Contains
$containsi Contains (case-insensitive)
$startswith Starts with
$endswith Ends with

Some Examples:

GET /api/v1/users?filter[gender][$in][0]=1&filter[gender][$in][1]=2
GET /api/v1/users?filter[gender][$between][0]=1&filter[gender][$between][1]=2
GET /api/v1/users?filter[firstName][$contains]=abc

$and and $or operator:

GET /api/v1/users/filter[$and][0][firstName][$containsi]="sa"&filter[$and][1][lastName][$eq]="Tran"
{
  "filter": {
    "$and": {
      "firstName": "sa",
      "lastName": "Tran"
    }
  }
}
GET /api/v1/users/filter[$or][0][$and][0][claims][claimValue][$eq]=admin&filter[$or][1][lastName][$eq]=Tran
{
    "filter": {
        "$or": {
            "$and":{
                "claims": {
                    "claimValue": "admin"
                }
            },
            "lastName": "Tran"
        }
    }
}

For more examples and get better understand, you can visit

https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#filtering
https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#complex-filtering
https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication#deep-filtering

'Cause I designed filter input based on Strapi filter

To know how to binding from LHS to Dynamic object you could see my Clean Architecture Project Project

This file help you to grab filter string query

This will help you how to binding from LHS to Dynamic object

var query = httpContext?.Request.QueryString.Value;
string[] stringQuery = ModelBindingExtension.GetFilterQueries(query);

List<QueryResult> queries =
        [
            .. StringExtension.TransformStringQuery(stringQuery),
        ];
object filter = StringExtension.Parse(queries);
await dbContext.User.Filter(filter).ToListAsync();

I'll Update full of them for the next version.

Sort

This example sorts users by name descending, then by age ascending when names are equal.

await dbContext.User.sort("name:desc, age").ToListAsync();

Pagination

Offset

   await dbContext.User.ToPagedListAsync(1, 10);

Cursor

  • Before : The previous Cursor
  • After : The next cursor
  • Size : Size of page
  • Sort : User sort request
  • UniqueSort : the property that is unique to make the mechanism work property, the default is Id:asc
await dbContext.User.ToCursorPagedListAsync(request);
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 (1)

Showing the top 1 popular GitHub repositories that depend on TranMinhSang.DynamicQueryExtension.EntityFrameworkCore:

Repository Stars
minhsangdotcom/clean-architecture
Clean Architecture Solution Template is for .NET Core🚀.
Version Downloads Last Updated
0.1.1 145 8/13/2025
0.1.0 127 8/13/2025