Interface IDistinctValuesProjectionStore<TProjection>
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
ISP sub-interface for projection stores that support optimized distinct value queries.
public interface IDistinctValuesProjectionStore<TProjection> : IProjectionStore<TProjection>, IServiceProvider where TProjection : class
Type Parameters
TProjectionThe projection type. Must be a reference type.
- Inherited Members
- Extension Methods
Remarks
Providers implement this interface to offer native distinct value extraction
(e.g., SELECT DISTINCT in SQL, aggregation pipeline in MongoDB,
terms aggregation in Elasticsearch). This avoids the default fallback which
loads all matching projections into memory.
Consumers use the extension method DistinctValuesAsync<TProjection>(IProjectionStore<TProjection>, string, IDictionary<string, object>?, CancellationToken) which automatically detects and uses this interface when available:
var statuses = await store.DistinctValuesAsync("Status", null, ct);
// Returns: ["Active", "Completed", "Cancelled"]
Methods
DistinctValuesAsync(string, IDictionary<string, object>?, CancellationToken)
Gets the distinct values of a specified property across all projections matching the given filters, using a provider-native query.
[RequiresUnreferencedCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
[RequiresDynamicCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
Task<IReadOnlyList<object>> DistinctValuesAsync(string propertyName, IDictionary<string, object>? filters, CancellationToken cancellationToken)
Parameters
propertyNamestringThe property name to extract distinct values from.
filtersIDictionary<string, object>Optional dictionary-based filter conditions to scope the distinct values. Pass
nullfor no filtering.cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<object>>
A read-only list of distinct values for the specified property.