PepperX.QueryForge 1.0.5

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

Part of PepperX Ecosystem

PepperX.QueryForge Logo

PepperX.QueryForge

NuGet Version .NET License

PepperX.QueryForge is the abstract, provider-agnostic foundation of the QueryForge ecosystem. It provides the core models, fluent builders, and bulletproof validation engines required to construct dynamic, paginated, and hierarchically grouped queries.

⚠️ Important: This package defines the intent and structure of the query but does not execute it. To execute queries against a database, you must install an execution provider like PepperX.QueryForge.Dapper.


📑 Table of Contents


✨ Core Features

  • Abstract & Provider-Agnostic: Define your query intent once in C# or JSON. Execute it anywhere by plugging in a provider (Dapper, EF Core, InMemory).
  • Bulletproof Security: Built-in SilentStrip validation engine prevents schema enumeration, data dumps, and malicious column requests before the query ever reaches the database.
  • Zero Boilerplate: Beautiful Fluent API for building queries in C#, or accept them as raw JSON payloads directly from frontends.
  • Complex Logic Trees: Natively supports deeply nested AND / OR / AND NOT logic groups.

🧩 The Provider Ecosystem

This core library is automatically included as a dependency when you install an execution provider.

Provider Package Status
Dapper (SQL Server) PepperX.QueryForge.Dapper ✅ Released
Entity Framework Core PepperX.QueryForge.EFCore 🔧 In Development
In-Memory (Testing) PepperX.QueryForge.InMemory 📋 Planned

🏗️ Core Concepts

The Base Query vs. Provider Queries

To prevent frontends from spoofing target tables (e.g., sending "object": {"name": "AdminPasswords"}), your API endpoints should accept the base PepperX.QueryForge.Query class. The backend then securely upgrades it to a provider-specific query (like DapperQuery).

// Frontend sends this JSON (Notice: No 'object' property — it's physically impossible to spoof)
// { "paging": { "size": 10 }, "sortColumns": [{"columnName": "Score", "sortOrder": 1}] }

// The backend maps the frontend criteria, paging, and sorting securely.

🔍 Advanced Filtering

QueryForge supports deeply nested logical groups and a comprehensive set of comparison operators.

C# Builder Syntax

var criteria = new QueryCriteria(
    logic: Logic.And,
    groups: [
        new ConditionGroup(
            logic: Logic.Or,
            conditions: [
                new Condition("Country", ConditionOperator.Equals, "USA"),
                new Condition("Country", ConditionOperator.Equals, "Germany")
            ]
        ),
        new ConditionGroup(
            logic: Logic.AndNot,
            conditions: [
                new Condition("Role", ConditionOperator.Equals, "Guest"),
                new Condition("Age", ConditionOperator.LessThan, 21)
            ]
        )
    ]
);

Equivalent JSON Payload (from Frontend)

{
  "criteria": {
    "logic": 0,
    "groups": [
      {
        "logic": 1,
        "conditions": [
          { "columnName": "Country", "operator": 0, "value": "USA" },
          { "columnName": "Country", "operator": 0, "value": "Germany" }
        ]
      },
      {
        "logic": 2,
        "conditions": [
          { "columnName": "Role", "operator": 0, "value": "Guest" },
          { "columnName": "Age", "operator": 6, "value": 21 }
        ]
      }
    ]
  }
}

🌳 Hierarchical Grouping Models

By specifying GroupByColumns, the core models define how the execution provider should transform a flat tabular result into a deeply nested hierarchical tree.

var query = QueryBuilder.New()
    .GroupBy(
        new GroupByDescriptor("Country", SortOrder.Ascending),
        new GroupByDescriptor("Department", SortOrder.Ascending)
    )
    .Page(5, 1) // Paginates the TOP-LEVEL groups
    .Build();

Target JSON Structure (Handled by Providers)

{
  "meta": { "total": { "rows": 2, "pages": 1 }, "type": "Grouped" },
  "groups": [
    {
      "key": "USA",
      "count": 45,
      "subGroups": [
        {
          "key": "IT",
          "count": 20,
          "items": [ { "userId": 1, "name": "Alice" } ]
        }
      ]
    }
  ]
}

🛡️ Security & Validation Engine

Never trust frontend query payloads. The core validation engine can either silently sanitize malicious requests or throw strict errors.

Silently removes denied columns and clamps pagination limits without throwing errors.

query.Validate(rules =>
{
    // Prevent sensitive column leakage
    rules.Select(c => c.Deny("PasswordHash", "SecretKey", "DeletedAt"));
    
    // Prevent data-dump attacks
    rules.PageSize(p => p.Max(100));
}, ValidationMode.SilentStrip);

Throws a QueryValidationException containing a list of all violated rules.

try 
{
    query.Validate(rules => rules.Select(c => c.Deny("PasswordHash")), ValidationMode.ThrowException);
}
catch (QueryValidationException ex)
{
    // ex.InvalidProperties contains ["PasswordHash"]
}

📚 Enum Reference

When sending JSON payloads from the frontend, enums are serialized as integers by default.

ConditionOperator

Value Name SQL Equivalent
0 Equals = @val (or IS NULL if value is null)
1 NotEquals <> @val (or IS NOT NULL if value is null)
2 Contains LIKE '%@val%'
3 NotContains NOT LIKE '%@val%'
4 StartsWith LIKE '@val%'
5 EndsWith LIKE '%@val'
6 LessThan < @val
7 GreaterThan > @val
8 LessThanOrEqualTo <= @val
9 GreaterThanOrEqualTo >= @val
10 Between BETWEEN @val AND @valTo

Logic

Value Name SQL Equivalent
0 And (...) AND (...)
1 Or (...) OR (...)
2 AndNot (...) AND NOT (...)
3 OrNot (...) OR NOT (...)

SortOrder

Value Name SQL Equivalent
0 Ascending ORDER BY col ASC
1 Descending ORDER BY col DESC

🤝 Contributing & License

This project is part of the PepperX Ecosystem. Licensed under the 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 (1)

Showing the top 1 NuGet packages that depend on PepperX.QueryForge:

Package Downloads
PepperX.QueryForge.Dapper

High-performance execution provider for the PepperX.QueryForge core library. It translates abstract query models into optimized SQL and executes them against Microsoft SQL Server using Dapper, seamlessly handling hierarchical grouping, complex filtering, and Stored Procedure/TVF integration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 103 7/11/2026
1.0.5 111 7/10/2026
1.0.4 106 7/10/2026
1.0.3 108 7/10/2026
1.0.1 105 7/10/2026
1.0.0 105 7/10/2026