marten-querying

Query Marten event store documents and projections using LINQ, compiled, batched, and raw SQL.

Updated Apr 21, 2026
One-click install
npx skills add https://github.com/erikshafer/CritterCab --skill marten-querying
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: marten-querying
Source: https://github.com/erikshafer/CritterCab/tree/main/docs/skills/marten-querying
Command: npx skills add https://github.com/erikshafer/CritterCab --skill marten-querying

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill addresses the challenge of querying read-side documents and projections in Marten efficiently, providing a seamless way to retrieve and analyze data stored in Marten event stores.

Core Features & Use Cases

  • Standard LINQ: Perform everyday queries with standard LINQ for the everyday case.
  • Compiled Queries: Optimize frequently called queries by compiling them for better performance.
  • Batched Queries: Execute multiple independent queries in a single round trip for efficiency.
  • Query Plans: Reusable queries that can run from multiple call sites with a single source of truth.
  • Raw JSON: Access raw JSONB data for forwarding to a cache or interfacing with non-.NET code.
  • Raw SQL: Execute complex queries using raw SQL for full control over the query logic.
  • Streaming JSON to HTTP: Stream JSONB data directly to HTTP responses for high-performance endpoints.
  • Use Case: When developing a read-side service that needs to query Marten documents and projections to fetch data for an application, this Skill can be used to streamline the query process.

Quick Start

Run the 'GetRideData' script to retrieve trip data from the Marten database.

Frequently Asked Questions about marten-querying

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

FAQPage Schema
How do I query Marten documents and projections efficiently for data retrieval?

To query Marten documents and projections efficiently, you can use standard LINQ for everyday cases, compiled queries for hot paths, batched queries for multiple round trips, and raw SQL for complex logic. This Skill streamlines the entire query process for read-side endpoints.

What is the best way to optimize frequently called Marten queries?

The best way to optimize frequently called Marten queries is by using compiled queries. Compiled queries cache the query plan for hot paths, significantly improving performance over standard LINQ for repetitive data retrieval operations.

Can I execute multiple independent Marten queries in a single round trip?

Yes, you can execute multiple independent Marten queries in a single round trip using batched queries. This approach reduces network latency and improves efficiency when you need to retrieve various documents or projections simultaneously.

How do I stream JSONB data directly from Marten to an HTTP response?

You can stream JSONB data directly from Marten to an HTTP response for high-performance endpoints. This Skill supports accessing raw JSONB data, allowing you to forward it directly to caches or interface with non-.NET code without deserialization overhead.

When should I use raw SQL instead of LINQ to query a Marten event store?

You should use raw SQL instead of LINQ to query a Marten event store when you need full control over complex query logic that standard LINQ cannot express. This approach is suitable for complex analytics and data retrieval scenarios requiring database-specific features.

Does this Skill support reusable query plans for multiple call sites?

Yes, this Skill supports reusable query plans that can run from multiple call sites with a single source of truth. This ensures consistency across your Marten-based application when executing identical data retrieval operations from different endpoints.