Class LockScope<T, TKey>
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
TTKey
- Inheritance
-
LockScope<T, TKey>
- Implements
-
IEquatable<LockScope<T, TKey>>
- Derived
- Inherited Members
Properties
Entity
public T Entity { get; }
Property Value
- T
Methods
AbandonAsync()
Releases the lock without any changes.
public Task AbandonAsync()
Returns
CommitAsync(CommitMode, T)
Apply the chosen mode and release the lock.
public Task<T> CommitAsync(CommitMode mode, T updatedEntity = null)
Parameters
modeCommitModeUpdate writes
updatedEntity(or the originally locked entity if null) and clears the lock; Delete deletes the document.updatedEntityTFor 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
exceptionException