Skip to content

JimGeersinga/MediatR.Chained

Repository files navigation

CI Pipeline

Documentation will be added soon...

MediatR.Chained

NuGet NuGet

Overview

The MediatorChain class is a part of the MediatR.Chained library and is used to create and execute a chain of commands or requests sequentially. It provides a fluent interface for adding requests to the chain and executing them asynchronously.

Installation

You can install the MediatR.Chained library via NuGet. Run the following command in the NuGet Package Manager Console:

dotnet add package MediatR.Chained

Usage

To use the MediatorChain class, follow these steps:

  1. Create an instance of the MediatorChain class by passing an instance of the IMediator interface and a list of MediatorChainStep objects representing the steps in the chain.

  2. Use the Add method to add requests to the chain. There are two overloads of the Add method:

    • The first overload takes a request object of type IRequest<TNext> and adds it to the chain. It returns the next mediator chain with the added request.
    • The second overload takes a function that creates a request based on the previous result. It returns the next mediator chain with the added request.
  3. Use the FailWhen method to add a condition to the chain that fails when the specified predicate returns true. This method is only available when using a mediator chain with a previous result.

  4. Use the SendAsync method to execute the chain of requests asynchronously and retrieve the response. There are two overloads of the SendAsync method:

    • The first overload returns the response of type TResponse.
    • The second overload returns the response as an object.

Here's an example of how to use the MediatorChain class: image

MediatR.Chained.EntityFrameworkCore

NuGet NuGet

Installation

You can install the MediatR.Chained.EntityFrameworkCore library via NuGet. Run the following command in the NuGet Package Manager Console:

dotnet add package MediatR.Chained.EntityFrameworkCore

Usage

coming soon...

License

This library is licensed under the MIT License. See the LICENSE file for more details.

About

Adds request chaining capability for MediatR

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages