Back to Graphql Platform

Marten

website/src/docs/hotchocolate/v16/integrations/marten.md

16.1.0-p.1.101.7 KB
Original Source

The HotChocolate.Data package generally works with any LINQ provider that provides an IQueryable<T>. However, Marten requires special handling. Pagination and projections work out of the box, but filtering and sorting need LINQ expressions translated into a format that the Marten LINQ provider can process. This integration provides custom configurations for that purpose.

You can find a sample project in Hot Chocolate Examples.

Get Started

Install the HotChocolate.Data.Marten package:

<PackageInstallation packageName="HotChocolate.Data.Marten" />

Filtering

Register the Marten filtering convention on the schema builder:

csharp
builder
    .AddGraphQL()
    .AddQueryType<Query>()
    .AddMartenFiltering();

Learn more about filtering.

Sorting

Register the Marten sorting convention on the schema builder:

csharp
builder
    .AddGraphQL()
    .AddQueryType<Query>()
    .AddMartenSorting();

Learn more about sorting.

Projections

Projections work out of the box with Marten. No custom configuration is needed.

Learn more about projections.

Paging

Pagination works out of the box with Marten. No custom configuration is needed.

Learn more about pagination.

Next Steps