AzureGems.MediatR.Extensions 3.0.1

dotnet add package AzureGems.MediatR.Extensions --version 3.0.1
NuGet\Install-Package AzureGems.MediatR.Extensions -Version 3.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AzureGems.MediatR.Extensions" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzureGems.MediatR.Extensions --version 3.0.1
#r "nuget: AzureGems.MediatR.Extensions, 3.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AzureGems.MediatR.Extensions as a Cake Addin
#addin nuget:?package=AzureGems.MediatR.Extensions&version=3.0.1

// Install AzureGems.MediatR.Extensions as a Cake Tool
#tool nuget:?package=AzureGems.MediatR.Extensions&version=3.0.1

AzureGems MediatR Extensions

Extension library for the popular MediatR library by Jimmy Bogard to add clear distinction between requests without any side-effects (aka Reads or Queries) or requests with side-effects (aka Writes or Commands).

Queries and QueryHandlers

Create a Query class and inherit from IQuery<out TResult>:

public class GetRecipeByName : IQuery<Recipe>
{
    public string RecipeName {get; set;}
    ...
}

To send / execute the query, use the SendQuery() extension on the standard IMediator interface.

var yummySpaghetti = new GetRecipeByName()
{
    RecipeName = "Spaghetti Bolognese"
}

Recipe recipe = await _mediator.SendQuery(yummySpaghetti);

Create a handler for the GetRecipe query that executes the required business logic to obtain a result:

public class GetRecipeHandler : IQueryHandler<GetRecipe, Recipe>
{
    ...
    public async Task<Recipe> Handle(GetRecipe query, CancellationToken ct)
    {
        ...
    }
}

Commands & CommandHandlers

Create a Command class and inherit from ICommand<out TResult>:

public class CreateRecipe : ICommand<Guid>
{
    public string Name {get; set;}
    public string Cuisine {get; set;}
    public Ingredient[] Ingredients {get; set;}
    ...
}

To send / execute the command, use the SendCommand() extension on the standard IMediator interface.

var yummySpaghetti = new CreateRecipe()
{
    Name = "Spaghetti Bolognese",
    Cuisine = "Italian",
    Ingredients = new[]
    {
        new Ingredient() { Name = "Spaghetti", WeightInGrams = "500"},
        new Ingredient() { Name = "Bolognese Sauce", VolumeInMilliliters = "500"},
        new Ingredient() { Name = "Parmesan cheese", WeightInGrams = "250"},
    }
}

Guid recipeId = await _mediator.SendCommand(yummySpaghetti);

Create a handler for the CreateRecipe command that executes the required business logic:

public class CreateRecipeHandler : ICommandHandler<CreateRecipe, Guid>
{
    ...
    public async Task<Guid> Handle(CreateRecipe cmd, CancellationToken ct)
    {
        ...
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 259 2/23/2023
3.0.0 216 2/23/2023
2.0.1 351 2/9/2021
2.0.0 297 2/9/2021
1.1.0 503 1/22/2020
1.0.0 467 1/5/2020