Skip to main content
Table of Contents

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

DateTimeOffset

CustomerId

Identifier of the customer that owns this tenant.

public Guid CustomerId { get; set; }

Property Value

Guid

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

string

DeletedAt

Timestamp at which the tenant was soft-deleted, or null while active.

public DateTimeOffset? DeletedAt { get; set; }

Property Value

DateTimeOffset?

Id

The tenant's stable identifier (stream id for the event-sourced aggregate).

public Guid Id { get; set; }

Property Value

Guid

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

bool

IsDeleted

true when DeletedAt has a value.

public bool IsDeleted { get; }

Property Value

bool

LastModifiedAt

Timestamp of the most recent mutating event, or null if untouched since creation.

public DateTimeOffset? LastModifiedAt { get; set; }

Property Value

DateTimeOffset?

Name

Human-readable tenant name.

public string Name { get; set; }

Property Value

string

Methods

Apply(TenantActivated)

Apply method that flips IsActive back to true.

[UsedImplicitly]
public void Apply(TenantActivated @event)

Parameters

event TenantActivated

The activation event.

Apply(TenantAssignedToCustomer)

Apply method that re-parents the tenant to a different customer.

[UsedImplicitly]
public void Apply(TenantAssignedToCustomer @event)

Parameters

event TenantAssignedToCustomer

The 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

event TenantCreated

The event that opened the stream.

Apply(TenantDeactivated)

Apply method that flips IsActive to false.

[UsedImplicitly]
public void Apply(TenantDeactivated @event)

Parameters

event TenantDeactivated

The deactivation event.

Apply(TenantDefaultLocaleChanged)

Apply method that swaps the DefaultLocale.

[UsedImplicitly]
public void Apply(TenantDefaultLocaleChanged @event)

Parameters

event TenantDefaultLocaleChanged

The locale-change event.

Apply(TenantDeleted)

Apply method for the soft-delete transition. Sets DeletedAt.

[UsedImplicitly]
public void Apply(TenantDeleted @event)

Parameters

event TenantDeleted

The delete event.

Apply(TenantRenamed)

Apply method for renaming. Updates Name and LastModifiedAt.

[UsedImplicitly]
public void Apply(TenantRenamed @event)

Parameters

event TenantRenamed

The rename event.