Class SparseFieldSetCache
- Namespace
- JsonApiDotNetCore.Queries
- Assembly
- JsonApiDotNetCore.dll
Takes sparse fieldsets from IQueryConstraintProviders and invokes OnApplySparseFieldSet(SparseFieldSetExpression?) on them.
public sealed class SparseFieldSetCache : ISparseFieldSetCache
- Inheritance
-
SparseFieldSetCache
- Implements
- Inherited Members
Remarks
This cache ensures that for each request (or operation per request), the resource definition callback is executed only twice per resource type. The first invocation is used to obtain the fields to retrieve from the underlying data store, while the second invocation is used to determine which fields to write to the response body.
Constructors
SparseFieldSetCache(IEnumerable<IQueryConstraintProvider>, IResourceDefinitionAccessor)
public SparseFieldSetCache(IEnumerable<IQueryConstraintProvider> constraintProviders, IResourceDefinitionAccessor resourceDefinitionAccessor)
Parameters
constraintProviders
IEnumerable<IQueryConstraintProvider>resourceDefinitionAccessor
IResourceDefinitionAccessor
Methods
GetIdAttributeSetForRelationshipQuery(ResourceType)
Gets the set of attributes to retrieve from the underlying data store for relationship endpoints. This always returns 'id', along with any additional attributes from resource definition callback.
public IImmutableSet<AttrAttribute> GetIdAttributeSetForRelationshipQuery(ResourceType resourceType)
Parameters
resourceType
ResourceType
Returns
GetSparseFieldSetForQuery(ResourceType)
Gets the set of sparse fields to retrieve from the underlying data store. Returns an empty set to retrieve all fields.
public IImmutableSet<ResourceFieldAttribute> GetSparseFieldSetForQuery(ResourceType resourceType)
Parameters
resourceType
ResourceType
Returns
GetSparseFieldSetForSerializer(ResourceType)
Gets the evaluated set of sparse fields to serialize into the response body.
public IImmutableSet<ResourceFieldAttribute> GetSparseFieldSetForSerializer(ResourceType resourceType)
Parameters
resourceType
ResourceType
Returns
Reset()
Resets the cached results from resource definition callbacks.
public void Reset()