Table of Contents

Interface IUnitOfWork

Namespace
GroupeIsa.Neos.Domain.Persistence
Assembly
GroupeIsa.Neos.Domain.Abstractions.dll

Unit of work.

public interface IUnitOfWork

Properties

InSaving

Gets or sets a value indicating whether the unit of work is saving data changes.

bool InSaving { get; set; }

Property Value

bool

InTransaction

Gets a value indicating whether the unit of work is executing within a database transaction.

bool InTransaction { get; }

Property Value

bool

Methods

BeginTransactionAsync()

Asynchronously begins a database transaction.

Task BeginTransactionAsync()

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method increments the transaction reference counter. When the counter is equal to zero, the method actually starts the transaction. Successive calls will increment the counter with the same transaction in progress.

BeginTransactionAsync(CancellationToken)

Asynchronously begins a database transaction.

Task BeginTransactionAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method increments the transaction reference counter. When the counter is equal to zero, the method actually starts the transaction. Successive calls will increment the counter with the same transaction in progress.

CommitTransactionAsync()

Asynchronously commits the database transaction.

Task CommitTransactionAsync()

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method decrements the transaction reference counter. When the counter reaches zero, the method actually commits the transaction. Intermediate calls will decrement the counter without validating the current transaction.

CommitTransactionAsync(CancellationToken)

Asynchronously commits the database transaction.

Task CommitTransactionAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method decrements the transaction reference counter. When the counter reaches zero, the method actually commits the transaction. Intermediate calls will decrement the counter without validating the current transaction.

RollbackTransactionAsync()

Asynchronously rolls back a transaction from a pending state.

Task RollbackTransactionAsync()

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method sets the transaction reference counter to zero.

RollbackTransactionAsync(CancellationToken)

Asynchronously rolls back a transaction from a pending state.

Task RollbackTransactionAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method sets the transaction reference counter to zero.

SaveAsync()

Asynchronously saves all changes made in this unit of work to the underlying database.

Task<Result> SaveAsync()

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains an FluentResults.Result object indicating success or failure of the saving operation.

SaveAsync(SaveMode, SaveOptions?, CancellationToken)

Asynchronously saves all changes made in this unit of work using the specified save mode and options.

Task<Result> SaveAsync(SaveMode mode, SaveOptions? options, CancellationToken cancellationToken = default)

Parameters

mode SaveMode

The SaveMode to use for the save operation.

options SaveOptions

Save options.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains an FluentResults.Result object indicating success or failure of the saving operation. For ThrowOnError, an exception is thrown instead of returning a failed Result.

Exceptions

Exception

Thrown when mode is ThrowOnError and validation or saving fails.

SaveAsync(SaveMode, CancellationToken)

Asynchronously saves all changes made in this unit of work using the specified save mode.

Task<Result> SaveAsync(SaveMode mode, CancellationToken cancellationToken = default)

Parameters

mode SaveMode

The SaveMode to use for the save operation.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains an FluentResults.Result object indicating success or failure of the saving operation. For ThrowOnError, an exception is thrown instead of returning a failed Result.

Exceptions

Exception

Thrown when mode is ThrowOnError and validation or saving fails.

SaveAsync(SaveOptions?, CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database with save options.

Task<Result> SaveAsync(SaveOptions? options, CancellationToken cancellationToken = default)

Parameters

options SaveOptions

Save options.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains an FluentResults.Result object indicating success or failure of the saving operation.

SaveAsync(CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database.

Task<Result> SaveAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains an FluentResults.Result object indicating success or failure of the saving operation.

SaveOrThrowAsync(SaveOptions?, CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database, throwing an exception on error instead of returning a failed Result.

Task SaveOrThrowAsync(SaveOptions? options, CancellationToken cancellationToken = default)

Parameters

options SaveOptions

Save options.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task representing the asynchronous operation.

Exceptions

Exception

Thrown when validation or saving fails.

SaveOrThrowAsync(CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database, throwing an exception on error instead of returning a failed Result.

Task SaveOrThrowAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task representing the asynchronous operation.

Exceptions

Exception

Thrown when validation or saving fails.

TrySaveAsync(SaveOptions?, CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database, catching all exceptions and returning them as failed Results.

Task<Result> TrySaveAsync(SaveOptions? options, CancellationToken cancellationToken = default)

Parameters

options SaveOptions

Save options.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains a FluentResults.Result object indicating success or failure of the saving operation.

TrySaveAsync(CancellationToken)

Asynchronously saves all changes made in this unit of work to the underlying database, catching all exceptions and returning them as failed Results.

Task<Result> TrySaveAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<Result>

A Task representing the asynchronous operation. The task result contains a FluentResults.Result object indicating success or failure of the saving operation.