Muonroi.Mapping.Abstractions 1.0.0-alpha.16

This is a prerelease version of Muonroi.Mapping.Abstractions.
dotnet add package Muonroi.Mapping.Abstractions --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.Mapping.Abstractions -Version 1.0.0-alpha.16
                    
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="Muonroi.Mapping.Abstractions" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Mapping.Abstractions" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Mapping.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muonroi.Mapping.Abstractions --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.Mapping.Abstractions, 1.0.0-alpha.16"
                    
#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.
#:package Muonroi.Mapping.Abstractions@1.0.0-alpha.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.Mapping.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Mapping.Abstractions&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.Mapping.Abstractions

Entity-DTO mapping contracts with a template method base class for schema-divergent multi-tenancy.

NuGet License: Apache 2.0

This is a contracts-only package — it ships IEntityMapper<TEntity, TDto> and EntityMapperBase<TEntity, TDto> with no runtime behavior of its own. The concrete mapping logic lives in your application or in a package that depends on this one (e.g. Muonroi.Services, which requires IEntityMapper<TEntity, TDto> to be registered in DI).

The template method pattern in EntityMapperBase separates core fields (shared across all tenants, always mapped) from site-specific fields (schema-divergent, overridden per deployment), making it straightforward to support multi-tenant schemas without branching in service code.

Installation

dotnet add package Muonroi.Mapping.Abstractions --prerelease

Quick Start

1. Implement the mapper

Derive from EntityMapperBase<TEntity, TDto> and implement the two abstract methods. Override the virtual site-specific hooks only when a tenant deployment has extra schema columns.

using Muonroi.Mapping.Abstractions;

public sealed class ProductMapper : EntityMapperBase<Product, ProductDto>
{
    // Required: map shared fields from entity → DTO.
    protected override void MapCoreToDto(Product entity, ProductDto dto)
    {
        dto.Id    = entity.Id;
        dto.Name  = entity.Name;
        dto.Price = entity.Price;
    }

    // Required: map mutable fields from DTO → entity.
    // Id is managed by the store; omit it here.
    protected override void MapCoreToEntity(ProductDto dto, Product entity)
    {
        entity.Name  = dto.Name;
        entity.Price = dto.Price;
    }

    // Optional: map site-specific (schema-divergent) fields.
    // Default implementation is a no-op — override only when needed.
    // protected override void MapSiteSpecificToDto(Product entity, ProductDto dto) { ... }
    // protected override void MapSiteSpecificToEntity(ProductDto dto, Product entity) { ... }
}

2. Register in DI

builder.Services.AddScoped<IEntityMapper<Product, ProductDto>, ProductMapper>();

3. Consume in a service

public sealed class ProductService(AppDbContext context, IEntityMapper<Product, ProductDto> mapper)
    : MServiceBase<Product, ProductDto>(context, mapper)
{
    // MServiceBase calls mapper.ToDto / ToEntity / ApplyUpdate automatically.
}

Features

  • IEntityMapper<TEntity, TDto> — three-method mapping contract: ToDto, ToEntity, and ApplyUpdate (patch an existing entity in place for update scenarios).
  • EntityMapperBase<TEntity, TDto> — template method implementation that calls MapCoreToDto / MapCoreToEntity for shared fields and MapSiteSpecificToDto / MapSiteSpecificToEntity (virtual no-ops) for tenant-divergent fields.
  • No reflection, no code generation, no configuration — pure hand-written mappings that remain fast and debuggable.
  • Designed to satisfy the IEntityMapper dependency required by Muonroi.Services.MServiceBase.

Configuration

No DI extension method is provided — this package is contracts only. Register your concrete mapper directly:

// Scoped lifetime matches the typical EF Core DbContext lifetime.
services.AddScoped<IEntityMapper<MyEntity, MyDto>, MyMapper>();

API Reference

Type Purpose
IEntityMapper<TEntity, TDto> Mapping contract: ToDto, ToEntity, ApplyUpdate
EntityMapperBase<TEntity, TDto> Abstract base implementing the template method pattern; requires TEntity : class, new() and TDto : class, new()

Samples

  • Quickstart.Services — Registers ProductMapper : EntityMapperBase<Product, ProductDto> and wires it into MServiceBase<Product, ProductDto> for full CRUD over an in-memory EF Core store.

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)
  • Muonroi.ServicesMServiceBase<TEntity, TDto> depends on IEntityMapper<TEntity, TDto>; pair these two packages for EF Core CRUD services.
  • Muonroi.Data.Abstractions — entity base contracts (IEntityBase, IAuditable, ISiteScoped) that your TEntity types typically implement.

License

Apache-2.0. See LICENSE-APACHE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Muonroi.Mapping.Abstractions:

Package Downloads
Muonroi.Services.Abstractions

Generic service base with virtual hook methods for schema-divergent multi-tenancy. Core provides CRUD; site overrides hooks.

Muonroi.Services

Generic EF Core service base with virtual hook methods for schema-divergent multi-tenancy. Core provides CRUD; site overrides hooks. This is an implementation layer (couples to DbContext by design) — not a vendor-neutral contract, hence not an .Abstractions assembly.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.16 52 6/22/2026
1.0.0-alpha.15 61 5/31/2026
1.0.0-alpha.14 64 5/15/2026
1.0.0-alpha.13 57 5/2/2026
1.0.0-alpha.12 71 4/2/2026
1.0.0-alpha.11 64 4/2/2026
1.0.0-alpha.9 64 3/30/2026
1.0.0-alpha.8 153 3/28/2026
1.0.0-alpha.7 69 3/27/2026
1.0.0-alpha.5 60 3/27/2026
1.0.0-alpha.4 65 3/27/2026
1.0.0-alpha.3 64 3/27/2026
1.0.0-alpha.2 60 3/26/2026