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
constraintProvidersIEnumerable<IQueryConstraintProvider>resourceDefinitionAccessorIResourceDefinitionAccessoroptionsIJsonApiOptionspaginationContextIPaginationContexttargetedFieldsITargetedFieldsevaluatedIncludeCacheIEvaluatedIncludeCachesparseFieldSetCacheISparseFieldSetCache
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
idTIdprimaryResourceTypeResourceTypefieldSelectionTopFieldSelection
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
relationshipRelationshipAttributerightResourceIdsICollection<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
primaryResourceIIdentifiable
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
hasManyRelationshipHasManyAttributeleftIdTIdrightResourceIdsICollection<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
idTIdprimaryResourceTypeResourceType
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
requestResourceTypeResourceType
Returns
ComposeSecondaryLayerForRelationship(ResourceType)
Collects constraints and builds the secondary layer for a relationship endpoint.
public QueryLayer ComposeSecondaryLayerForRelationship(ResourceType secondaryResourceType)
Parameters
secondaryResourceTypeResourceType
Returns
GetFilter(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual FilterExpression? GetFilter(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScopeIReadOnlyCollection<QueryExpression>resourceTypeResourceType
Returns
GetIncludeElements(IImmutableSet<IncludeElementExpression>, ResourceType)
protected virtual IImmutableSet<IncludeElementExpression> GetIncludeElements(IImmutableSet<IncludeElementExpression> includeElements, ResourceType resourceType)
Parameters
includeElementsIImmutableSet<IncludeElementExpression>resourceTypeResourceType
Returns
GetPagination(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual PaginationExpression GetPagination(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScopeIReadOnlyCollection<QueryExpression>resourceTypeResourceType
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
primaryResourceTypeResourceType
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
primaryIdTIdhasManyRelationshipHasManyAttribute
Returns
Type Parameters
TId
GetSelectionForSparseAttributeSet(ResourceType)
protected virtual FieldSelection? GetSelectionForSparseAttributeSet(ResourceType resourceType)
Parameters
resourceTypeResourceType
Returns
GetSort(IReadOnlyCollection<QueryExpression>, ResourceType)
protected virtual SortExpression? GetSort(IReadOnlyCollection<QueryExpression> expressionsInScope, ResourceType resourceType)
Parameters
expressionsInScopeIReadOnlyCollection<QueryExpression>resourceTypeResourceType
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
secondaryLayerQueryLayerprimaryResourceTypeResourceTypeprimaryIdTIdrelationshipRelationshipAttribute
Returns
Type Parameters
TId