Class EntityPagedQuery<TReadModel>
- Namespace
- Arbiter.CommandQuery.Queries
- Assembly
- Arbiter.CommandQuery.dll
Represents a query for retrieving paged entities based on an EntityQuery. The result of the query will be of type EntityPagedResult<TReadModel>.
public record EntityPagedQuery<TReadModel> : CacheableQueryBase<EntityPagedResult<TReadModel>>, IRequest<EntityPagedResult<TReadModel>>, IRequest, IEquatable<PrincipalCommandBase<EntityPagedResult<TReadModel>>>, IEquatable<PrincipalQueryBase<EntityPagedResult<TReadModel>>>, ICacheResult, IEquatable<CacheableQueryBase<EntityPagedResult<TReadModel>>>, IEquatable<EntityPagedQuery<TReadModel>>
Type Parameters
TReadModel
The type of the read model returned as the result of the query.
- Inheritance
-
PrincipalCommandBase<EntityPagedResult<TReadModel>>PrincipalQueryBase<EntityPagedResult<TReadModel>>CacheableQueryBase<EntityPagedResult<TReadModel>>EntityPagedQuery<TReadModel>
- Implements
-
IRequest<EntityPagedResult<TReadModel>>IEquatable<EntityPagedQuery<TReadModel>>
- Inherited Members
Examples
The following example demonstrates how to use the EntityPagedQuery<TReadModel>:
var principal = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "JohnDoe") }));
var entityQuery = new EntityQuery
{
Filter = new EntityFilter { Name = "Status", Operator = "eq", Value = "Active" },
Sort = new List<EntitySort> { new EntitySort { Name = "Name", Direction = "asc" } },
Page = 1,
PageSize = 20
};
var query = new EntityPagedQuery<ProductReadModel>(principal, entityQuery);
// Send the query to the mediator instance
var result = await mediator.Send(query);
Console.WriteLine($"Total Results: {result?.Total}");
Remarks
This query is typically used in a CQRS (Command Query Responsibility Segregation) pattern to retrieve entities in a paginated format. The EntityQuery allows filtering, sorting, and pagination criteria to be specified.
Constructors
EntityPagedQuery(ClaimsPrincipal?, EntityQuery?)
Initializes a new instance of the EntityPagedQuery<TReadModel> class.
public EntityPagedQuery(ClaimsPrincipal? principal, EntityQuery? query)
Parameters
principal
ClaimsPrincipalThe ClaimsPrincipal representing the user executing the query.
query
EntityQueryThe EntityQuery defining the filter, sort, and pagination criteria for the query.
Properties
Query
Gets the EntityQuery defining the filter, sort, and pagination criteria for the query.
[JsonPropertyName("query")]
public EntityQuery Query { get; }
Property Value
Methods
GetCacheKey()
Generates a cache key for the query based on the EntityQuery.
public override string GetCacheKey()
Returns
- string
A string representing the cache key for the query.
GetCacheTag()
Gets the cache tag associated with the TReadModel
.
public override string? GetCacheTag()