Table of Contents

Class ResourceRepositoryAccessor

Namespace
JsonApiDotNetCore.Repositories
Assembly
JsonApiDotNetCore.dll

Retrieves an IResourceRepository<TResource, TId> instance from the D/I container and invokes a method on it.

[PublicAPI]
public class ResourceRepositoryAccessor : IResourceRepositoryAccessor
Inheritance
ResourceRepositoryAccessor
Implements
Inherited Members

Constructors

ResourceRepositoryAccessor(IServiceProvider, IResourceGraph, IJsonApiRequest)

public ResourceRepositoryAccessor(IServiceProvider serviceProvider, IResourceGraph resourceGraph, IJsonApiRequest request)

Parameters

serviceProvider IServiceProvider
resourceGraph IResourceGraph
request IJsonApiRequest

Methods

AddToToManyRelationshipAsync<TResource, TId>(TResource?, TId, ISet<IIdentifiable>, CancellationToken)

public Task AddToToManyRelationshipAsync<TResource, TId>(TResource? leftResource, TId leftId, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken) where TResource : class, IIdentifiable<TId>

Parameters

leftResource TResource
leftId TId
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource
TId

CountAsync(ResourceType, FilterExpression?, CancellationToken)

Invokes CountAsync(FilterExpression?, CancellationToken) for the specified resource type.

public Task<int> CountAsync(ResourceType resourceType, FilterExpression? filter, CancellationToken cancellationToken)

Parameters

resourceType ResourceType
filter FilterExpression
cancellationToken CancellationToken

Returns

Task<int>

CreateAsync<TResource>(TResource, TResource, CancellationToken)

Invokes CreateAsync(TResource, TResource, CancellationToken) for the specified resource type.

public Task CreateAsync<TResource>(TResource resourceFromRequest, TResource resourceForDatabase, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

resourceFromRequest TResource
resourceForDatabase TResource
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

DeleteAsync<TResource, TId>(TResource?, TId, CancellationToken)

Invokes DeleteAsync(TResource?, TId, CancellationToken) for the specified resource type.

public Task DeleteAsync<TResource, TId>(TResource? resourceFromDatabase, TId id, CancellationToken cancellationToken) where TResource : class, IIdentifiable<TId>

Parameters

resourceFromDatabase TResource
id TId
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource
TId

GetAsync(ResourceType, QueryLayer, CancellationToken)

Invokes GetAsync(QueryLayer, CancellationToken) for the specified resource type.

public Task<IReadOnlyCollection<IIdentifiable>> GetAsync(ResourceType resourceType, QueryLayer queryLayer, CancellationToken cancellationToken)

Parameters

resourceType ResourceType
queryLayer QueryLayer
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<IIdentifiable>>

GetAsync<TResource>(QueryLayer, CancellationToken)

Invokes GetAsync(QueryLayer, CancellationToken) for the specified resource type.

public Task<IReadOnlyCollection<TResource>> GetAsync<TResource>(QueryLayer queryLayer, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

queryLayer QueryLayer
cancellationToken CancellationToken

Returns

Task<IReadOnlyCollection<TResource>>

Type Parameters

TResource

GetForCreateAsync<TResource, TId>(Type, TId, CancellationToken)

Invokes GetForCreateAsync(Type, TId, CancellationToken) for the specified resource type.

public Task<TResource> GetForCreateAsync<TResource, TId>(Type resourceClrType, TId id, CancellationToken cancellationToken) where TResource : class, IIdentifiable<TId>

Parameters

resourceClrType Type
id TId
cancellationToken CancellationToken

Returns

Task<TResource>

Type Parameters

TResource
TId

GetForUpdateAsync<TResource>(QueryLayer, CancellationToken)

Invokes GetForUpdateAsync(QueryLayer, CancellationToken) for the specified resource type.

public Task<TResource?> GetForUpdateAsync<TResource>(QueryLayer queryLayer, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

queryLayer QueryLayer
cancellationToken CancellationToken

Returns

Task<TResource>

Type Parameters

TResource

RemoveFromToManyRelationshipAsync<TResource>(TResource, ISet<IIdentifiable>, CancellationToken)

public Task RemoveFromToManyRelationshipAsync<TResource>(TResource leftResource, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

ResolveReadRepository(ResourceType)

protected virtual object ResolveReadRepository(ResourceType resourceType)

Parameters

resourceType ResourceType

Returns

object

ResolveReadRepository(Type)

protected object ResolveReadRepository(Type resourceClrType)

Parameters

resourceClrType Type

Returns

object

ResolveWriteRepository(Type)

protected virtual object ResolveWriteRepository(Type resourceClrType)

Parameters

resourceClrType Type

Returns

object

SetRelationshipAsync<TResource>(TResource, object?, CancellationToken)

Invokes SetRelationshipAsync(TResource, object?, CancellationToken) for the specified resource type.

public Task SetRelationshipAsync<TResource>(TResource leftResource, object? rightValue, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

leftResource TResource
rightValue object
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource

UpdateAsync<TResource>(TResource, TResource, CancellationToken)

Invokes UpdateAsync(TResource, TResource, CancellationToken) for the specified resource type.

public Task UpdateAsync<TResource>(TResource resourceFromRequest, TResource resourceFromDatabase, CancellationToken cancellationToken) where TResource : class, IIdentifiable

Parameters

resourceFromRequest TResource
resourceFromDatabase TResource
cancellationToken CancellationToken

Returns

Task

Type Parameters

TResource