Table of Contents

Interface IDbContextTransactionLock

Namespace
NuvTools.Data.EntityFrameworkCore.Context
Assembly
NuvTools.Data.EntityFrameworkCore.dll

Provider-specific implementation of the transaction-scoped lock behind AcquireTransactionLockAsync(string, CancellationToken).

public interface IDbContextTransactionLock

Remarks

Every relational database offers this, under a different name and keyed differently — pg_advisory_xact_lock on PostgreSQL, sp_getapplock on SQL Server — so the statement lives in the provider package, not here. The implementation is registered by that package's AddDatabase/AddDatabaseByConnectionName helpers, and DbContextBase resolves it from the application service provider.

Methods

AcquireAsync(DbContext, string, CancellationToken)

Acquires the exclusive lock named name, blocking until it is granted, and holds it until the current transaction of context ends.

Task AcquireAsync(DbContext context, string name, CancellationToken cancellationToken = default)

Parameters

context DbContext

The context whose transaction and connection the lock belongs to.

name string

Lock name, as given by the caller.

cancellationToken CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

Task

A task that completes once the lock is held.