criteria-query-pattern

Implement CriteriaModel and ICriteria<T> to translate model criteria into IQueryable<T> for dynamic filtering, sorting, and pagination.

1|Updated Feb 28, 2024
One-click install
npx skills add https://github.com/Sparkymod/Template --skill criteria-query-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: criteria-query-pattern
Source: https://github.com/Sparkymod/Template/tree/main/.claude/skills/criteria-query-pattern
Command: npx skills add https://github.com/Sparkymod/Template --skill criteria-query-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps implement or consume dynamic filtering, sorting, and pagination for entities, ensuring server-driven dynamic filtering and enhancing query surface hardening.

Core Features & Use Cases

  • Dynamic Filtering: Allows for flexible client-side filtering of data based on various conditions.
  • Sorting and Pagination: Facilitates sorting and pagination for efficient data handling.
  • Use Case: Ideal for scenarios where a client needs to interact with a large dataset, such as a search or report feature in an application.

Quick Start

Apply the criteria-query-pattern to implement a dynamic search feature in your application.

Frequently Asked Questions about criteria-query-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement dynamic filtering, sorting, and pagination for entities?

Dynamic filtering, sorting, and pagination for entities is implemented using the CriteriaModel and ICriteria<T> framework. You translate model criteria into an IQueryable<T> by implementing the ApplyCriteriaFromModel method for efficient query execution.

What is the best way to harden a query surface for server-driven data retrieval?

Server-driven data retrieval and query surface hardening are achieved by applying the criteria-query-pattern framework. It uses a CriteriaModel to securely translate client-side filtering conditions into a controlled IQueryable<T> execution.

How do I handle dynamic client-side filtering conditions over large datasets?

Dynamic client-side filtering over large datasets is handled by passing flexible conditions to a CriteriaModel. The server then processes these conditions through ICriteria<T> to safely filter and retrieve the required data.

Does this query design pattern require specific dependencies for dynamic sorting?

This query design pattern for dynamic sorting requires no external dependencies. It operates by implementing the ApplyCriteriaFromModel method to translate sorting and pagination criteria directly into an IQueryable<T>.

When should I use a CriteriaModel for data retrieval instead of static queries?

You should use a CriteriaModel for data retrieval when building search or report features where clients need to interact with large datasets. It provides the flexible dynamic filtering, sorting, and pagination that static queries cannot easily support.