Class EntityDeleteCommand<TKey, TReadModel>
- Namespace
- Arbiter.CommandQuery.Commands
- Assembly
- Arbiter.CommandQuery.dll
A command to delete an entity based on the specified identifier.
TReadModel
represents the result of the command.
public record EntityDeleteCommand<TKey, TReadModel> : EntityIdentifierCommand<TKey, TReadModel>, IRequest<TReadModel>, IRequest, IEquatable<PrincipalCommandBase<TReadModel>>, IEquatable<EntityIdentifierCommand<TKey, TReadModel>>, ICacheExpire, IEquatable<EntityDeleteCommand<TKey, TReadModel>>
Type Parameters
TKey
The type of the key used to identify the entity.
TReadModel
The type of the read model returned after the command execution.
- Inheritance
-
PrincipalCommandBase<TReadModel>EntityIdentifierCommand<TKey, TReadModel>EntityDeleteCommand<TKey, TReadModel>
- Implements
-
IRequest<TReadModel>IEquatable<PrincipalCommandBase<TReadModel>>IEquatable<EntityIdentifierCommand<TKey, TReadModel>>IEquatable<EntityDeleteCommand<TKey, TReadModel>>
- Inherited Members
Examples
The following example demonstrates how to use the EntityDeleteCommand<TKey, TReadModel>:
var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "JohnDoe") }));
var command = new EntityDeleteCommand<int, ProductReadModel>(principal, 123);
// Pass the command to a handler or mediator
var result = await mediator.Send(command);
Remarks
This command is typically used in a CQRS (Command Query Responsibility Segregation) pattern to delete an entity and optionally return a read model representing the deleted entity or a related result.
Constructors
EntityDeleteCommand(ClaimsPrincipal?, TKey)
Initializes a new instance of the EntityDeleteCommand<TKey, TReadModel> class.
public EntityDeleteCommand(ClaimsPrincipal? principal, TKey id)
Parameters
principal
ClaimsPrincipalThe ClaimsPrincipal representing the user executing the command.
id
TKeyThe identifier of the entity to be deleted.
Exceptions
- ArgumentNullException
Thrown when
id
is null.