Table of Contents

Class UntenantedContext

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

The tenant context of a caller that is deliberately not scoped to any tenant, exposed so that "explicitly untenanted" is something a caller can say rather than something they leave unsaid.

public sealed class UntenantedContext : ITenantContext
Inheritance
UntenantedContext
Implements
Inherited Members
Extension Methods

Remarks

Stores that partition rows by tenant resolve that partition from an ITenantContext. Where the dependency is optional, a caller cannot distinguish deciding to run untenanted from forgetting to supply a context, and the same store answers the partition question two different ways depending on what happens to be registered in the container. The two answers name different partitions, so rows written under one stop being visible under the other and nothing errors. Naming this instance removes the second answer: the dependency stays required, and a caller who wants no tenant scoping passes this.

Register this only on a deployment that has enabled multi-tenancy. It names the untenanted partition, which is a live partition only while multi-tenancy is active. On a deployment that has not enabled it, the framework registers its own single-tenant context automatically and a store's startup schema handshake may converge rows anchored to the untenanted term onto the single-tenant identity -- so a context pinned here would go on reading a partition its rows had been migrated out of. Registering it on such a deployment is refused at startup rather than allowed to reach that state; a single-tenant host needs no context of its own and should register none.

Absence of a tenant is a VALUE here, not a missing one. TenantId is the untenanted partition's own identifier and HasTenant is therefore true -- a caller in this context is scoped, to the partition that holds untenanted rows. Reporting no tenant would invite a consumer to omit the partition term altogether, which is the defect this type exists to prevent.

Properties

HasTenant

Gets a value indicating whether a partition is resolved.

public bool HasTenant { get; }

Property Value

bool

Always true: the untenanted partition is a partition.

Instance

Gets the shared instance.

public static UntenantedContext Instance { get; }

Property Value

UntenantedContext

The single UntenantedContext; it carries no per-caller state.

TenantId

Gets the untenanted partition's identifier.

public string? TenantId { get; }

Property Value

string

The untenanted sentinel -- never null and never empty.