Muonroi.Mapping.Abstractions
1.0.0-alpha.16
dotnet add package Muonroi.Mapping.Abstractions --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Mapping.Abstractions -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Mapping.Abstractions" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Mapping.Abstractions" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Mapping.Abstractions" />
paket add Muonroi.Mapping.Abstractions --version 1.0.0-alpha.16
#r "nuget: Muonroi.Mapping.Abstractions, 1.0.0-alpha.16"
#:package Muonroi.Mapping.Abstractions@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Mapping.Abstractions&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Mapping.Abstractions&version=1.0.0-alpha.16&prerelease
Muonroi.Mapping.Abstractions
Entity-DTO mapping contracts with a template method base class for schema-divergent multi-tenancy.
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, andApplyUpdate(patch an existing entity in place for update scenarios).EntityMapperBase<TEntity, TDto>— template method implementation that callsMapCoreToDto/MapCoreToEntityfor shared fields andMapSiteSpecificToDto/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
IEntityMapperdependency required byMuonroi.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 intoMServiceBase<Product, ProductDto>for full CRUD over an in-memory EF Core store.
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.Services—MServiceBase<TEntity, TDto>depends onIEntityMapper<TEntity, TDto>; pair these two packages for EF Core CRUD services.Muonroi.Data.Abstractions— entity base contracts (IEntityBase,IAuditable,ISiteScoped) that yourTEntitytypes typically implement.
License
Apache-2.0. See LICENSE-APACHE.
| Product | Versions 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. |
-
net8.0
- Muonroi.Data.Abstractions (>= 1.0.0-alpha.16)
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 |