Class Tenant
- Namespace
- Stratara.Domain.Multitenancy
- Assembly
- Stratara.Domain.dll
The Stratara framework's built-in tenant aggregate — the top-level isolation unit for multitenant applications. Created on tenant onboarding, mutated by the lifecycle events in TenantCreated, TenantRenamed, TenantActivated, TenantDeactivated, TenantDefaultLocaleChanged, TenantAssignedToCustomer, and TenantDeleted.
public sealed class Tenant : IAggregate
- Inheritance
-
Tenant
- Implements
- Inherited Members
- Extension Methods
Remarks
Public setters are intentional — the Stratara snapshot deserializer needs them. State
transitions go through Apply(...) methods so that event-sourced rebuild and
snapshot-hydration both result in the same shape.
Properties
CreatedAt
Timestamp the tenant aggregate was first created.
public DateTimeOffset CreatedAt { get; set; }
Property Value
CustomerId
Identifier of the customer that owns this tenant.
public Guid CustomerId { get; set; }
Property Value
DefaultLocale
IETF BCP 47 language tag used as the tenant's default UI locale (e.g. en-US).
Defaults to Empty so the framework stays culture-neutral; the
consumer supplies the actual value through DefaultLocale.
public string DefaultLocale { get; set; }
Property Value
DeletedAt
Timestamp at which the tenant was soft-deleted, or null while active.
public DateTimeOffset? DeletedAt { get; set; }
Property Value
Id
The tenant's stable identifier (stream id for the event-sourced aggregate).
public Guid Id { get; set; }
Property Value
IsActive
true while the tenant is operational; false when deactivated via
TenantDeactivated. Deletion (DeletedAt) is a separate axis.
public bool IsActive { get; set; }
Property Value
IsDeleted
true when DeletedAt has a value.
public bool IsDeleted { get; }
Property Value
LastModifiedAt
Timestamp of the most recent mutating event, or null if untouched since creation.
public DateTimeOffset? LastModifiedAt { get; set; }
Property Value
Name
Human-readable tenant name.
public string Name { get; set; }
Property Value
Methods
Apply(TenantActivated)
Apply method that flips IsActive back to true.
[UsedImplicitly]
public void Apply(TenantActivated @event)
Parameters
eventTenantActivatedThe activation event.
Apply(TenantAssignedToCustomer)
Apply method that re-parents the tenant to a different customer.
[UsedImplicitly]
public void Apply(TenantAssignedToCustomer @event)
Parameters
eventTenantAssignedToCustomerThe customer-reassignment event.
Apply(TenantCreated)
Apply method invoked by the event-source replay when a TenantCreated event is encountered.
[UsedImplicitly]
public void Apply(TenantCreated @event)
Parameters
eventTenantCreatedThe event that opened the stream.
Apply(TenantDeactivated)
Apply method that flips IsActive to false.
[UsedImplicitly]
public void Apply(TenantDeactivated @event)
Parameters
eventTenantDeactivatedThe deactivation event.
Apply(TenantDefaultLocaleChanged)
Apply method that swaps the DefaultLocale.
[UsedImplicitly]
public void Apply(TenantDefaultLocaleChanged @event)
Parameters
eventTenantDefaultLocaleChangedThe locale-change event.
Apply(TenantDeleted)
Apply method for the soft-delete transition. Sets DeletedAt.
[UsedImplicitly]
public void Apply(TenantDeleted @event)
Parameters
eventTenantDeletedThe delete event.
Apply(TenantRenamed)
Apply method for renaming. Updates Name and LastModifiedAt.
[UsedImplicitly]
public void Apply(TenantRenamed @event)
Parameters
eventTenantRenamedThe rename event.