Common.QueryKit 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Common.QueryKit --version 1.0.1
                    
NuGet\Install-Package Common.QueryKit -Version 1.0.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="Common.QueryKit" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Common.QueryKit" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Common.QueryKit" />
                    
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 Common.QueryKit --version 1.0.1
                    
#r "nuget: Common.QueryKit, 1.0.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 Common.QueryKit@1.0.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=Common.QueryKit&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Common.QueryKit&version=1.0.1
                    
Install as a Cake Tool

Common.QueryKit

Common.QueryKit is a lightweight, EF Core–safe query composition library for dynamic filtering, sorting, and paging built on top of IQueryable.

It is designed for enterprise-grade ASP.NET Core applications where:

  • Queries must remain SQL-translatable
  • Performance and index usage matter
  • Dynamic LINQ and string-based hacks are avoided

Ideal for ERP systems, School Management Systems, Admin Panels, and Reporting APIs.


✨ Core Features (Detailed)

✅ EF Core SQL–Translatable Expressions

All queries are built using expression trees, ensuring:

  • Full SQL translation by EF Core
  • No client-side evaluation
  • Database indexes remain effective

✅ Nested Property Filtering

Filter using navigation properties via dot notation.

Property = "Class.Name"

EF Core automatically translates navigation access into proper SQL joins.

Example:

new FilterRule
{
    Property = "Class.Name",
    Operator = FilterOperator.Contains,
    Value = "Grade"
}

✅ Multi-Column Sorting

Supports multiple sorting rules with preserved order.

options.Sorts.Add(new SortRule { Property = "Class.Name" });
options.Sorts.Add(new SortRule { Property = "CreatedDate", Descending = true });

Equivalent SQL:

ORDER BY Class.Name ASC, CreatedDate DESC

✅ Strongly-Typed Filter Operators

Filter behavior is defined using an enum, ensuring clarity and safety.

FilterOperator.Contains
FilterOperator.Equals
FilterOperator.Between

✅ Range Filters (Between)

Perfect for date and numeric ranges.

new FilterRule
{
    Property = "CreatedDate",
    Operator = FilterOperator.Between,
    From = DateTime.Today.AddDays(-30),
    To = DateTime.Today
}

✅ Null-Safe Comparisons

Safely compare nullable fields.

new FilterRule
{
    Property = "DeletedDate",
    Operator = FilterOperator.Equals,
    Value = null
}

✅ Allowed Property Whitelist (Security)

Restrict filtering and sorting to approved fields.

var whitelist = new PropertyWhitelist(new[]
{
    "Name",
    "Class.Name",
    "CreatedDate"
});

Prevents:

  • Invalid property access
  • Accidental data exposure
  • User-driven property injection

✅ Pagination Helpers

Clean and predictable paging.

query.PageBy(page: 2, size: 25);

Produces SQL OFFSET/FETCH pagination.


📦 Installation

dotnet add package Common.QueryKit

🚀 Quick Start

Entity Example

public class Student
{
    public string Name { get; set; }
    public Class Class { get; set; }
    public DateTime CreatedDate { get; set; }
}

Build Query Options

var options = new QueryOptions
{
    Page = 1,
    PageSize = 20
};

options.Filters.Add(new FilterRule
{
    Property = "Class.Name",
    Operator = FilterOperator.Contains,
    Value = "Grade"
});

options.Sorts.Add(new SortRule
{
    Property = "CreatedDate",
    Descending = true
});

Apply to IQueryable

var result = db.Students
    .ApplyFilters(options.Filters)
    .ApplySorting(options.Sorts)
    .PageBy(options.Page, options.PageSize)
    .ToList();

🔎 Supported Filter Operators

Operator Description
Equals Exact match
Contains String contains
StartsWith Prefix match
EndsWith Suffix match
GreaterThan Numeric/date comparison
LessThan Numeric/date comparison
Between Range filtering
In Collection match

🧠 Design Philosophy

  • Expressions over strings
  • SQL first, not in-memory
  • Explicit over implicit
  • Predictable performance
  • Small, composable API

🧩 When to Use

  • Generic list screens
  • Admin dashboards
  • Search APIs
  • Reporting modules

❌ Avoid

  • Complex domain logic
  • Aggregate-heavy queries

📌 Requirements

  • .NET 10
  • Entity Framework Core

🧑‍💻 Author

Muammar Siddiqui
Innovador Solutions


📄 License

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

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.8 89 2/4/2026
1.0.7 89 1/9/2026
1.0.6 93 1/7/2026
1.0.5 97 1/1/2026
1.0.4 96 12/30/2025
1.0.3 98 12/27/2025
1.0.2 93 12/27/2025
1.0.1 89 12/27/2025
1.0.0 172 12/23/2025