Table of Contents

Class DatabaseEngineExtensions

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Convenience extensions for DatabaseEngine.

public static class DatabaseEngineExtensions
Inheritance
DatabaseEngineExtensions
Inherited Members

Methods

CreateQuickTransaction(DatabaseEngine, DurabilityMode, CommitDiscipline)

Creates a single-transaction UoW with auto-dispose semantics. When the returned transaction is disposed, the backing UoW is also disposed automatically.

public static Transaction CreateQuickTransaction(this DatabaseEngine dbe, DurabilityMode durabilityMode = DurabilityMode.Deferred, CommitDiscipline discipline = CommitDiscipline.TickFence)

Parameters

dbe DatabaseEngine

The database engine.

durabilityMode DurabilityMode

Controls when WAL records become crash-safe. Default is Deferred.

discipline CommitDiscipline

Durability discipline for SingleVersion-layout writes (TickFence default, or Commit for zero-loss, atomic, commit-scoped writes). Fixed for the transaction.

Returns

Transaction

A transaction whose Dispose() also disposes the owning UoW.

Remarks

This is a convenience wrapper for the common single-transaction pattern:

using var tx = dbe.CreateQuickTransaction();
tx.Spawn<MyArchetype>();
tx.Commit();
// tx.Dispose() also disposes the backing UoW

Do not call this inside a tick. The name says "transaction", but the expensive half is the UNIT OF WORK: every call claims a UoW registry slot — bitmap claim, capacity growth, entry initialisation and the page writes that go with it — and gives it back on dispose. One per operation is a per-operation cost that reads as free at the call site, which is exactly what makes it a trap. A tick already has a unit of work; create transactions from it with CreateTransaction(CommitDiscipline) instead. A UoW is designed to host many — see the remarks on Flush(), "regardless of how many transactions the UoW hosts" — so there is nothing to gain by giving each one its own.

It remains the right call where a unit of work genuinely IS the unit of work: unit tests, one-shot setup, diagnostics, tooling, and any path where the cost is paid once rather than per entity per frame.

CreateReadOnlyTransaction(DatabaseEngine)

Creates a read-only transaction with no UnitOfWork and no ChangeSet allocation. Write operations (Create/Update/Delete) throw InvalidOperationException. Commit is a no-op. Dispose exits the epoch scope and removes from the chain.

public static Transaction CreateReadOnlyTransaction(this DatabaseEngine dbe)

Parameters

dbe DatabaseEngine

Returns

Transaction