Table of Contents

Interface IResourceWriteRepository<TResource, TId>

Namespace
JsonApiDotNetCore.Repositories
Assembly
JsonApiDotNetCore.dll

Groups write operations.

[PublicAPI]
public interface IResourceWriteRepository<TResource, in TId> where TResource : class, IIdentifiable<in TId>

Type Parameters

TResource

The resource type.

TId

The resource identifier type.

Methods

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

Adds resources to a to-many relationship in the underlying data store.

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

Parameters

leftResource TResource
leftId TId
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

CreateAsync(TResource, TResource, CancellationToken)

Creates a new resource in the underlying data store.

Task CreateAsync(TResource resourceFromRequest, TResource resourceForDatabase, CancellationToken cancellationToken)

Parameters

resourceFromRequest TResource
resourceForDatabase TResource
cancellationToken CancellationToken

Returns

Task

DeleteAsync(TResource?, TId, CancellationToken)

Deletes an existing resource from the underlying data store.

Task DeleteAsync(TResource? resourceFromDatabase, TId id, CancellationToken cancellationToken)

Parameters

resourceFromDatabase TResource
id TId
cancellationToken CancellationToken

Returns

Task

GetForCreateAsync(Type, TId, CancellationToken)

Creates a new resource instance, in preparation for CreateAsync(TResource, TResource, CancellationToken).

Task<TResource> GetForCreateAsync(Type resourceClrType, TId id, CancellationToken cancellationToken)

Parameters

resourceClrType Type
id TId
cancellationToken CancellationToken

Returns

Task<TResource>

Remarks

This method can be overridden to assign resource-specific required relationships.

GetForUpdateAsync(QueryLayer, CancellationToken)

Retrieves a resource with all of its attributes, including the set of targeted relationships, in preparation for UpdateAsync(TResource, TResource, CancellationToken).

Task<TResource?> GetForUpdateAsync(QueryLayer queryLayer, CancellationToken cancellationToken)

Parameters

queryLayer QueryLayer
cancellationToken CancellationToken

Returns

Task<TResource>

RemoveFromToManyRelationshipAsync(TResource, ISet<IIdentifiable>, CancellationToken)

Removes resources from a to-many relationship in the underlying data store.

Task RemoveFromToManyRelationshipAsync(TResource leftResource, ISet<IIdentifiable> rightResourceIds, CancellationToken cancellationToken)

Parameters

leftResource TResource
rightResourceIds ISet<IIdentifiable>
cancellationToken CancellationToken

Returns

Task

SetRelationshipAsync(TResource, object?, CancellationToken)

Performs a complete replacement of the relationship in the underlying data store.

Task SetRelationshipAsync(TResource leftResource, object? rightValue, CancellationToken cancellationToken)

Parameters

leftResource TResource
rightValue object
cancellationToken CancellationToken

Returns

Task

UpdateAsync(TResource, TResource, CancellationToken)

Updates the attributes and relationships of an existing resource in the underlying data store.

Task UpdateAsync(TResource resourceFromRequest, TResource resourceFromDatabase, CancellationToken cancellationToken)

Parameters

resourceFromRequest TResource
resourceFromDatabase TResource
cancellationToken CancellationToken

Returns

Task