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
TResourceleftId
TIdrightResourceIds
ISet<IIdentifiable>cancellationToken
CancellationToken
Returns
CreateAsync(TResource, TResource, CancellationToken)
Creates a new resource in the underlying data store.
Task CreateAsync(TResource resourceFromRequest, TResource resourceForDatabase, CancellationToken cancellationToken)
Parameters
resourceFromRequest
TResourceresourceForDatabase
TResourcecancellationToken
CancellationToken
Returns
DeleteAsync(TResource?, TId, CancellationToken)
Deletes an existing resource from the underlying data store.
Task DeleteAsync(TResource? resourceFromDatabase, TId id, CancellationToken cancellationToken)
Parameters
resourceFromDatabase
TResourceid
TIdcancellationToken
CancellationToken
Returns
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
Typeid
TIdcancellationToken
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
QueryLayercancellationToken
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
TResourcerightResourceIds
ISet<IIdentifiable>cancellationToken
CancellationToken
Returns
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
TResourcerightValue
objectcancellationToken
CancellationToken
Returns
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
TResourceresourceFromDatabase
TResourcecancellationToken
CancellationToken