Table of Contents

Class LockScope<T, TKey>

Namespace
Tharga.MongoDB.Lockable
Assembly
Tharga.MongoDB.dll

Scope returned by ILockableRepositoryCollection<TEntity, TKey>.LockAsync(...). The commit decision (Update vs Delete) is taken at commit time, not at lock time. Disposal without commit releases the lock unchanged (mirrors EntityScope<T, TKey>).

public record LockScope<T, TKey> : IAsyncDisposable, IDisposable, IEquatable<LockScope<T, TKey>> where T : LockableEntityBase<TKey>

Type Parameters

T
TKey
Inheritance
LockScope<T, TKey>
Implements
Derived
Inherited Members

Properties

Entity

public T Entity { get; }

Property Value

T

Methods

AbandonAsync()

Releases the lock without any changes.

public Task AbandonAsync()

Returns

Task

CommitAsync(CommitMode, T)

Apply the chosen mode and release the lock.

public Task<T> CommitAsync(CommitMode mode, T updatedEntity = null)

Parameters

mode CommitMode

Update writes updatedEntity (or the originally locked entity if null) and clears the lock; Delete deletes the document.

updatedEntity T

For Update, the new entity state. Ignored for Delete. If null on Update, the originally locked entity is committed unchanged.

Returns

Task<T>

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

SetErrorStateAsync(Exception)

Releases the lock and records an exception state on it (consistent with SetErrorStateAsync(Exception)).

public Task SetErrorStateAsync(Exception exception)

Parameters

exception Exception

Returns

Task