Table of Contents

Class QueryLayerComposer

Namespace
JsonApiDotNetCore.Queries
Assembly
JsonApiDotNetCore.dll

Takes scoped expressions from IQueryConstraintProviders and transforms them.

[PublicAPI]
public class QueryLayerComposer : IQueryLayerComposer
Inheritance
QueryLayerComposer
Implements
Inherited Members

Constructors

QueryLayerComposer(IEnumerable<IQueryConstraintProvider>, IResourceDefinitionAccessor, IJsonApiOptions, IPaginationContext, ITargetedFields, IEvaluatedIncludeCache, ISparseFieldSetCache)

public QueryLayerComposer(IEnumerable<IQueryConstraintProvider> constraintProviders, IResourceDefinitionAccessor resourceDefinitionAccessor, IJsonApiOptions options, IPaginationContext paginationContext, ITargetedFields targetedFields, IEvaluatedIncludeCache evaluatedIncludeCache, ISparseFieldSetCache sparseFieldSetCache)

Parameters

constraintProviders IEnumerable<IQueryConstraintProvider>
resourceDefinitionAccessor IResourceDefinitionAccessor
options IJsonApiOptions
paginationContext IPaginationContext
targetedFields ITargetedFields
evaluatedIncludeCache IEvaluatedIncludeCache
sparseFieldSetCache ISparseFieldSetCache

Methods

ComposeForGetById<TId>(TId, ResourceType, TopFieldSelection)

Collects constraints and builds a QueryLayer out of them, used to retrieve one resource.

public QueryLayer ComposeForGetById<TId>(TId id, ResourceType primaryResourceType, TopFieldSelection fieldSelection)

Parameters

id TId
primaryResourceType ResourceType
fieldSelection TopFieldSelection

Returns

QueryLayer

Type Parameters

TId

ComposeForGetRelationshipRightIds(RelationshipAttribute, ICollection<IIdentifiable>)

Builds a query for the specified relationship with a filter to match on its right resource IDs.

public QueryLayer ComposeForGetRelationshipRightIds(RelationshipAttribute relationship, ICollection<IIdentifiable> rightResourceIds)

Parameters

relationship RelationshipAttribute
rightResourceIds ICollection<IIdentifiable>

Returns

QueryLayer

ComposeForGetTargetedSecondaryResourceIds(IIdentifiable)

Builds a query for each targeted relationship with a filter to match on its right resource IDs.

public IEnumerable<(QueryLayer, RelationshipAttribute)> ComposeForGetTargetedSecondaryResourceIds(IIdentifiable primaryResource)

Parameters

primaryResource IIdentifiable

Returns

IEnumerable<(QueryLayer, RelationshipAttribute)>

ComposeForHasMany<TId>(HasManyAttribute, TId, ICollection<IIdentifiable>)

Builds a query for a to-many relationship with a filter to match on its left and right resource IDs.

public QueryLayer ComposeForHasMany<TId>(HasManyAttribute hasManyRelationship, TId leftId, ICollection<IIdentifiable> rightResourceIds)

Parameters

hasManyRelationship HasManyAttribute
leftId TId
rightResourceIds ICollection<IIdentifiable>

Returns

QueryLayer

Type Parameters

TId

ComposeForUpdate<TId>(TId, ResourceType)

Builds a query that retrieves the primary resource, including all of its attributes and all targeted relationships, during a create/update/delete request.

public QueryLayer ComposeForUpdate<TId>(TId id, ResourceType primaryResourceType)

Parameters

id TId
primaryResourceType ResourceType

Returns

QueryLayer

Type Parameters

TId

ComposeFromConstraints(ResourceType)

Collects constraints and builds a QueryLayer out of them, used to retrieve the actual resources.

public QueryLayer ComposeFromConstraints(ResourceType requestResourceType)

Parameters

requestResourceType ResourceType

Returns

QueryLayer

ComposeSecondaryLayerForRelationship(ResourceType)

Collects constraints and builds the secondary layer for a relationship endpoint.

public QueryLayer ComposeSecondaryLayerForRelationship(ResourceType secondaryResourceType)

Parameters

secondaryResourceType ResourceType

Returns

QueryLayer

GetFilter(IReadOnlyCollection<QueryExpression>, ResourceType)

protected virtual FilterExpression? GetFilter(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)

Parameters

expressionsInScope IReadOnlyCollection<QueryExpression>
resourceType ResourceType

Returns

FilterExpression

GetIncludeElements(IImmutableSet<IncludeElementExpression>, ResourceType)

protected virtual IImmutableSet<IncludeElementExpression> GetIncludeElements(IImmutableSet<IncludeElementExpression> includeElements, ResourceType resourceType)

Parameters

includeElements IImmutableSet<IncludeElementExpression>
resourceType ResourceType

Returns

IImmutableSet<IncludeElementExpression>

GetPagination(IReadOnlyCollection<QueryExpression>, ResourceType)

protected virtual PaginationExpression GetPagination(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)

Parameters

expressionsInScope IReadOnlyCollection<QueryExpression>
resourceType ResourceType

Returns

PaginationExpression

GetPrimaryFilterFromConstraints(ResourceType)

Builds a filter from constraints, used to determine total resource count on a primary collection endpoint.

public FilterExpression? GetPrimaryFilterFromConstraints(ResourceType primaryResourceType)

Parameters

primaryResourceType ResourceType

Returns

FilterExpression

GetSecondaryFilterFromConstraints<TId>(TId, HasManyAttribute)

Builds a filter from constraints, used to determine total resource count on a secondary collection endpoint.

public FilterExpression? GetSecondaryFilterFromConstraints<TId>(TId primaryId, HasManyAttribute hasManyRelationship)

Parameters

primaryId TId
hasManyRelationship HasManyAttribute

Returns

FilterExpression

Type Parameters

TId

GetSelectionForSparseAttributeSet(ResourceType)

protected virtual FieldSelection? GetSelectionForSparseAttributeSet(ResourceType resourceType)

Parameters

resourceType ResourceType

Returns

FieldSelection

GetSort(IReadOnlyCollection<QueryExpression>, ResourceType)

protected virtual SortExpression GetSort(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)

Parameters

expressionsInScope IReadOnlyCollection<QueryExpression>
resourceType ResourceType

Returns

SortExpression

WrapLayerForSecondaryEndpoint<TId>(QueryLayer, ResourceType, TId, RelationshipAttribute)

Wraps a layer for a secondary endpoint into a primary layer, rewriting top-level includes.

public QueryLayer WrapLayerForSecondaryEndpoint<TId>(QueryLayer secondaryLayer, ResourceType primaryResourceType, TId primaryId, RelationshipAttribute relationship)

Parameters

secondaryLayer QueryLayer
primaryResourceType ResourceType
primaryId TId
relationship RelationshipAttribute

Returns

QueryLayer

Type Parameters

TId