SharedCode.MediatR
7.3.8
See the version list below for details.
dotnet add package SharedCode.MediatR --version 7.3.8
NuGet\Install-Package SharedCode.MediatR -Version 7.3.8
<PackageReference Include="SharedCode.MediatR" Version="7.3.8" />
<PackageVersion Include="SharedCode.MediatR" Version="7.3.8" />
<PackageReference Include="SharedCode.MediatR" />
paket add SharedCode.MediatR --version 7.3.8
#r "nuget: SharedCode.MediatR, 7.3.8"
#:package SharedCode.MediatR@7.3.8
#addin nuget:?package=SharedCode.MediatR&version=7.3.8
#tool nuget:?package=SharedCode.MediatR&version=7.3.8
Shared Code
A collection of reusable utility libraries for .NET, published as individual NuGet packages. Each package targets a specific concern — from core extensions and domain primitives to data access, dependency injection, MediatR pipelines, ASP.NET Core helpers, and WPF utilities — so you can pull in only what you need.
Table of Contents
Packages
Requirements
- .NET 10 SDK (for
net10.0targets) - .NET 9 SDK (for
net9.0targets) - .NET 8 SDK (for
net8.0targets) - .NET Standard 2.0 / 2.1 targets are compatible with .NET Framework 4.6.1+ and .NET Core 2.0+
Installation
Install any package via the NuGet Package Manager, the .NET CLI, or by editing your project file.
.NET CLI
dotnet add package SharedCode.Core
dotnet add package SharedCode.Data
dotnet add package SharedCode.Data.CosmosDb
dotnet add package SharedCode.Data.EntityFramework
dotnet add package SharedCode.DependencyInjection
dotnet add package SharedCode.MediatR
dotnet add package SharedCode.Web
dotnet add package SharedCode.Windows.WPF
Package Manager Console
Install-Package SharedCode.Core
Install-Package SharedCode.Data
Install-Package SharedCode.Data.CosmosDb
Install-Package SharedCode.Data.EntityFramework
Install-Package SharedCode.DependencyInjection
Install-Package SharedCode.MediatR
Install-Package SharedCode.Web
Install-Package SharedCode.Windows.WPF
Package Details
SharedCode.Core
Core utilities and domain primitives that are shared across all other packages. Targets
netstandard2.0, netstandard2.1, net8.0, net9.0, and net10.0.
Highlights
- Extension methods —
DateTime,DateTimeOffset,string,int,Enum, collections,Type,IEnumerable, reflection, and more - Specification pattern — strongly typed
Specification<T>/Specification<T, TResult>with a fluent query builder (filter, ordering, paging, includes) - Domain primitives —
ValueObject,BaseException, result types (IResult,IErrorResult,ValidationErrorResult) - Security —
Hasherutility supporting multiple hash algorithms - Text —
StringExtensions,StringBuilderExtensions, masking helpers - Calendar — business-day arithmetic,
DateTimeFormat,DayOfWeekExtensions - Reactive — built on
System.ReactiveandSystem.Interactive - Threading — async-friendly utilities
Quick Start
// Add business days
var nextBusinessDay = DateTime.Today.AddBusinessDays(3);
// Specification pattern
public sealed class ActiveUsersSpec : Specification<User>
{
public ActiveUsersSpec() =>
this.Query.Where(u => u.IsActive).OrderBy(u => u.LastName);
}
SharedCode.Data
Framework-agnostic data access abstractions. Targets netstandard2.0, netstandard2.1,
net8.0, net9.0, and net10.0.
Highlights
IQueryRepository<T>/ICommandRepository<T>contractsQueryRepository<T>— default generic / in-memory implementationIQueryResult<T>with paging support viaPagingDescriptorandPageBoundryAddOrUpdatedescriptor patternDataReaderExtensions,DynamicDataRecord, and ODataDataServiceQueryExtensions
Quick Start
public class UserService
{
private readonly IQueryRepository<User> repository;
public UserService(IQueryRepository<User> repository) =>
this.repository = repository;
public async Task<IQueryResult<User>> GetActiveUsersAsync(CancellationToken ct) =>
await this.repository.ListAsync(new ActiveUsersSpec(), ct);
}
SharedCode.Data.CosmosDb
Azure Cosmos DB integration built on top of the official
Microsoft.Azure.Cosmos SDK.
Targets net8.0, net9.0, and net10.0.
Highlights
- Cosmos DB query helpers and logger extensions
Query<T>helper for building Cosmos DB LINQ queries
SharedCode.Data.EntityFramework
Entity Framework Core integration. Targets net8.0, net9.0, and net10.0.
Highlights
AuditableDbContext— automatically stampsCreatedAt/ModifiedAtonIAuditableEntityEfRepository<T>— EF Core implementation ofIQueryRepository<T>andICommandRepository<T>Entitybase class andIAuditableEntity/IAuditedEntityinterfaces- Specification evaluator wired directly into EF Core queries
IDataService/DataServicefor unit-of-work style operations
Quick Start
// Register with resilient SQL Server connection
services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(
connectionString,
sqlOptions => sqlOptions.EnableRetryOnFailure(
maxRetryCount: 10,
maxRetryDelay: TimeSpan.FromSeconds(30),
errorNumbersToAdd: null)));
SharedCode.DependencyInjection
Assembly scanning and automatic service registration. Targets netstandard2.0,
netstandard2.1, net8.0,