Table of Contents

Class EntityIdentifiersCommand<TKey, TResponse>

Namespace
Arbiter.CommandQuery.Commands
Assembly
Arbiter.CommandQuery.dll

Represents a base command for operations that require a list of identifiers.

public abstract record EntityIdentifiersCommand<TKey, TResponse> : PrincipalCommandBase<TResponse>, IRequest<TResponse>, IRequest, IEquatable<PrincipalCommandBase<TResponse>>, IEquatable<EntityIdentifiersCommand<TKey, TResponse>>

Type Parameters

TKey

The type of the key used to identify the entities.

TResponse

The type of the response returned by the command.

Inheritance
EntityIdentifiersCommand<TKey, TResponse>
Implements
IRequest<TResponse>
Inherited Members

Examples

The following example demonstrates how to use the EntityIdentifiersCommand<TKey, TResponse>:

public record DeleteEntitiesCommand : EntityIdentifiersCommand<int, ProductReadModel>
{
    public DeleteEntitiesCommand(ClaimsPrincipal principal, IReadOnlyCollection<int> ids)
        : base(principal, ids)
    {
    }
}

var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "JohnDoe") }));
var command = new DeleteEntitiesCommand(principal, new List<int> { 1, 2, 3 });

// Pass the command to a handler or mediator
var result = await mediator.Send(command);
Console.WriteLine($"Entities deleted: {result}");

Remarks

This class is typically used in a CQRS (Command Query Responsibility Segregation) pattern to define commands that operate on multiple entities identified by a collection of keys.

Constructors

EntityIdentifiersCommand(ClaimsPrincipal?, IReadOnlyCollection<TKey>)

Initializes a new instance of the EntityIdentifiersCommand<TKey, TResponse> class.

protected EntityIdentifiersCommand(ClaimsPrincipal? principal, IReadOnlyCollection<TKey> ids)

Parameters

principal ClaimsPrincipal

The ClaimsPrincipal representing the user executing the command.

ids IReadOnlyCollection<TKey>

The collection of identifiers for this command.

Exceptions

ArgumentNullException

Thrown when ids is null.

Properties

Ids

Gets the collection of identifiers for this command.

[JsonPropertyName("ids")]
public IReadOnlyCollection<TKey> Ids { get; }

Property Value

IReadOnlyCollection<TKey>

The collection of identifiers for this command.