Skip to main content
Table of Contents

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

service IAggregationService

The aggregation service.

streamId Guid

The aggregate's stream id.

tenantId Guid

The required Subject tenant id (typically sessionContext.TenantId).

cancellationToken CancellationToken

Propagated to the read.

Returns

Task<TAggregate>

The aggregate if loaded and tenant-matching; null otherwise.

Type Parameters

TAggregate

A tenant-owning aggregate type.