Table of Contents

Interface IUnitOfWorkService

Namespace
FishMMO.Database.Npgsql.Services.Interfaces
Assembly
FishMMO-DB.dll

Creates IUnitOfWork scopes to coordinate multiple service calls into a single explicit database transaction.

public interface IUnitOfWorkService

Remarks

A unit of work establishes an ambient NpgsqlDbContext and an explicit transaction for the current logical async flow. Services invoked inside the scope reuse that context and must not commit independently; the transaction is finalized by calling CommitAsync(CancellationToken) or RollbackAsync(CancellationToken).

Methods

BeginAsync(CancellationToken)

Begins a new unit of work for the current logical async flow.

Task<DatabaseResult<IUnitOfWork>> BeginAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<IUnitOfWork>>

A DatabaseResult<T> containing an active IUnitOfWork on success.

Remarks

The returned unit of work establishes an ambient NpgsqlDbContext. Service calls made within the scope will reuse that context and transaction.