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
IResourceDefinitionAccessoroptions
IJsonApiOptionspaginationContext
IPaginationContexttargetedFields
ITargetedFieldsevaluatedIncludeCache
IEvaluatedIncludeCachesparseFieldSetCache
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
TIdprimaryResourceType
ResourceTypefieldSelection
TopFieldSelection
Returns
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
RelationshipAttributerightResourceIds
ICollection<IIdentifiable>
Returns
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
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
HasManyAttributeleftId
TIdrightResourceIds
ICollection<IIdentifiable>
Returns
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
TIdprimaryResourceType
ResourceType
Returns
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
ComposeSecondaryLayerForRelationship(ResourceType)
Collects constraints and builds the secondary layer for a relationship endpoint.
public QueryLayer ComposeSecondaryLayerForRelationship(ResourceType secondaryResourceType)
Parameters
secondaryResourceType
ResourceType
Returns
GetFilter(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual FilterExpression? GetFilter(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScope
IReadOnlyCollection<QueryExpression>resourceType
ResourceType
Returns
GetIncludeElements(IImmutableSet<IncludeElementExpression>, ResourceType)
protected virtual IImmutableSet<IncludeElementExpression> GetIncludeElements(IImmutableSet<IncludeElementExpression> includeElements, ResourceType resourceType)
Parameters
includeElements
IImmutableSet<IncludeElementExpression>resourceType
ResourceType
Returns
GetPagination(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual PaginationExpression GetPagination(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScope
IReadOnlyCollection<QueryExpression>resourceType
ResourceType
Returns
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
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
TIdhasManyRelationship
HasManyAttribute
Returns
Type Parameters
TId
GetSelectionForSparseAttributeSet(ResourceType)
protected virtual FieldSelection? GetSelectionForSparseAttributeSet(ResourceType resourceType)
Parameters
resourceType
ResourceType
Returns
GetSort(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual SortExpression GetSort(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScope
IReadOnlyCollection<QueryExpression>resourceType
ResourceType
Returns
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
QueryLayerprimaryResourceType
ResourceTypeprimaryId
TIdrelationship
RelationshipAttribute
Returns
Type Parameters
TId