Mappah.Extensions 2.3.0

dotnet add package Mappah.Extensions --version 2.3.0
                    
NuGet\Install-Package Mappah.Extensions -Version 2.3.0
                    
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="Mappah.Extensions" Version="2.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Mappah.Extensions" Version="2.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Mappah.Extensions" />
                    
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 Mappah.Extensions --version 2.3.0
                    
#r "nuget: Mappah.Extensions, 2.3.0"
                    
#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 Mappah.Extensions@2.3.0
                    
#: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=Mappah.Extensions&version=2.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Mappah.Extensions&version=2.3.0
                    
Install as a Cake Tool

Mappah

NuGet version License: MIT Build Platform

Minimalist object-to-object mapper for .NET.


💡 Features

  • Auto-mapping properties by name
  • Custom property mapping with expressions (For)
  • Ignoring properties (Skip())
  • Reverse mapping support (WithReverse())
  • Nested mapping support (native, just configure both nested and parent entities)
  • ASP.NET Core integration via AddMappah()
  • Optimized collectio mapping via WithCollection()

🚀 Target Frameworks

📦 Installation

Install via NuGet:

dotnet add package Mappah

If you want to integrate with ASP.NET Core Dependency Injection:

dotnet add package Mappah.Extensions

🚀 Quick Start

Define a one-way mapping:

MapperConfigurationBuilder.Create<User, UserDto>()
    .For(dest => dest.FullName, src => src.FirstName + " " + src.LastName)
    .Skip(dest => dest.Password);

Or you can use WithReverse() to configure mapping backwards:

MapperConfigurationBuilder.Create<User, UserDto>()
    .For(dest => dest.FullName, src => src.FirstName + " " + src.LastName)
    .Skip(dest => dest.Password)
    .WithReverse()
    .For(dest => dest.FirstName, src => src.FullName.Split(' ')[0])
    .For(dest => dest.LastName, src => src.FullName.Split(' ')[1]);

Build the configuration after mapping definition:

MapperConfigurationBuilder.Build();

Use the mapper:

var mapper = new DefaultMapperResolver();

var user = new User { FirstName = "John", LastName = "Doe", Password = "123456" };
var userDto = mapper.Map<UserDto, User>(user);
// or implicitly
var anotherUserDto = mapper.Map<UserDto>(user);

// userDto.FullName == "John Doe"
// userDto.Password == null

🔧 Collection mapping optimization

Mappah supports nested and explisit mapping of collections It will recognize if mappable properties are collections automatically But you can improve performance if you explicitly configure what properties will be mapped as collections To do so you can use WithCollection(...)

 MapperConfigurationBuilder.Create<TypeA, TypeB>()
    .WithCollection(dest => dest.CollectionB, src => src.CollectionA);

This allows the expression tree builder to pre-compile mapping expression for your collection

🔧 ASP.NET Core Integration

builder.Services.AddMappah();

Inject IMapResolver anywhere:

public class MyService
{
    private readonly IMapResolver _mapper;

    public MyService(IMapResolver mapper)
    {
        _mapper = mapper;
    }
}

📝 License

Licensed under the MIT License.

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

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
2.3.0 159 5/5/2025
2.2.0 153 5/5/2025
2.1.0 147 4/28/2025
2.0.0 94 4/26/2025
1.3.0 96 4/26/2025
1.2.0 90 4/26/2025
1.1.0 95 4/26/2025
1.0.1 88 4/26/2025
1.0.0 89 4/26/2025