Class AggregationServiceTenantExtensions
- Namespace
- Stratara.Abstractions.EventSourcing
- Assembly
- Stratara.Abstractions.dll
Tenant-aware helpers on top of IAggregationService.
public static class AggregationServiceTenantExtensions
- Inheritance
-
AggregationServiceTenantExtensions
- Inherited Members
Methods
AggregateOwnedByTenantAsync<TAggregate>(IAggregationService, Guid, Guid, CancellationToken)
Aggregate a tenant-scoped aggregate AND assert that the loaded aggregate's
Subject tenant id matches tenantId. Returns null on
either "not found" or "loaded but wrong tenant" — letting the caller map both
to NotFound without leaking foreign-tenant existence.
public static Task<TAggregate?> AggregateOwnedByTenantAsync<TAggregate>(this IAggregationService service, Guid streamId, Guid tenantId, CancellationToken cancellationToken = default) where TAggregate : class, ITenantAggregate, new()
Parameters
serviceIAggregationServiceThe aggregation service.
streamIdGuidThe aggregate's stream id.
tenantIdGuidThe required Subject tenant id (typically
sessionContext.TenantId).cancellationTokenCancellationTokenPropagated to the read.
Returns
- Task<TAggregate>
The aggregate if loaded and tenant-matching;
nullotherwise.
Type Parameters
TAggregateA tenant-owning aggregate type.