Table of Contents

Interface IETagStampable

Namespace
Trellis
Assembly
Trellis.Core.dll

Infrastructure seam that lets a persistence adapter stamp an aggregate's optimistic-concurrency token (ETag) without reflection.

public interface IETagStampable
Extension Methods

Remarks

ETag is read-only on the domain surface — domain code must never assign it. The Trellis EF Core integration stamps it through the change tracker (AggregateETagInterceptor), which writes the value via EF metadata and never needs the CLR setter. A non-EF persistence adapter (Dapper, raw ADO, a Cosmos SDK repository, ...) has no such mechanism, so Aggregate<TId> implements this interface explicitly: the stamp method stays off the aggregate's public/domain surface and is reachable only by code that deliberately casts to IETagStampable.

Typical adapter usage:

// On load: restore the stored concurrency token.
((IETagStampable)aggregate).StampETag(row.ETag);

// On save: stamp a fresh, unquoted opaque token — e.g. Guid.NewGuid().ToString("N") to match the EF
// default — and use the previous value in the optimistic WHERE clause. A store-native token that comes
// quoted (such as a Cosmos _etag) must be normalized to its unquoted opaque form before stamping.
((IETagStampable)aggregate).StampETag(newETag);

Methods

StampETag(string)

Sets the aggregate's optimistic-concurrency token (ETag) to etag. For persistence infrastructure only — not domain code.

void StampETag(string etag)

Parameters

etag string

The concurrency token to stamp. Must be a valid unquoted RFC 9110 §8.8.1 opaque tag — non-null, non-whitespace, and free of double-quotes and control characters (e.g. Guid.NewGuid().ToString("N")). This is the value the HTTP layer emits as a strong ETag, so a store-native quoted token (such as a Cosmos _etag) must be normalized to its unquoted form first.

Exceptions

ArgumentNullException

etag is null.

ArgumentException

etag is empty, whitespace, or contains characters that are not valid in an RFC 9110 opaque tag.