Table of Contents

Class EntityScopeExtensions

Namespace
Tharga.MongoDB.Lockable
Assembly
Tharga.MongoDB.dll
public static class EntityScopeExtensions
Inheritance
EntityScopeExtensions
Inherited Members

Methods

ExecuteAsync<T, TKey>(EntityScope<T, TKey>, Func<T, Task<T>>, Action<Exception>)

Backwards-compatible overload — pass an Action<T> to handle errors thrown by func only; commit-side exceptions still propagate. New code should prefer the LockableErrorKind overload, which routes every failure path through a single callback.

public static Task<T> ExecuteAsync<T, TKey>(this EntityScope<T, TKey> item, Func<T, Task<T>> func, Action<Exception> errorHandler) where T : LockableEntityBase<TKey>

Parameters

item EntityScope<T, TKey>
func Func<T, Task<T>>
errorHandler Action<Exception>

Returns

Task<T>

Type Parameters

T
TKey

ExecuteAsync<T, TKey>(EntityScope<T, TKey>, Func<T, Task<T>>, Action<LockableErrorKind, Exception>)

The provided function should return an entity for commit and default for abandon. If this is a delete operation, return the entity to be deleted from 'func'.

public static Task<T> ExecuteAsync<T, TKey>(this EntityScope<T, TKey> item, Func<T, Task<T>> func, Action<LockableErrorKind, Exception> errorHandler = null) where T : LockableEntityBase<TKey>

Parameters

item EntityScope<T, TKey>

The entity scope.

func Func<T, Task<T>>

The function to be executed within the scope.

errorHandler Action<LockableErrorKind, Exception>

Receives a LockableErrorKind discriminator and the exception for every failure path — errors thrown by func as well as commit-side exceptions (LockExpiredException, LockAlreadyReleasedException, CommitException, any other commit failure). When null (default), the original exception propagates with its stack trace intact — same behavior as before this overload existed.

Returns

Task<T>

Type Parameters

T

Type of the entity.

TKey

Type of the key.

Exceptions

ArgumentNullException