MiniMapr is a lightweight, high-performance object-to-object mapper for .NET applications.
It was designed to offer developers a clean and minimal API to define custom mapping rules without the complexity or overhead of traditional mappers. Whether youβre working on a Web API, a background service, or a desktop app, MiniMapr provides a fast and extensible mapping solution.
IMapperConfigYou can get started by installing MiniMapr via NuGet:
dotnet add package MiniMapr
Install MiniMapr via NuGet:
dotnet add package MiniMapr
Letβs assume you have a domain model and a DTO:
public class User
{
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public Address Address { get; set; }
}
public class UserDto
{
public string Name { get; set; }
public string EmailAddress { get; set; }
public string Password { get; set; } = "";
public AddressDto Address { get; set; }
}
public class Address
{
public string Street { get; set; }
}
public class AddressDto
{
public string Street { get; set; }
}
To define how mapping should occur, implement IMapperConfig:
Example:
using MiniMapr;
public class UserMappingConfig : IMapperConfig
{
public void Configure(MapperService mapper)
{
mapper.Add<User, UserDto>(config =>
{
config.IgnoredProperties.Add("Password");
config.CustomMappings["Email"] = "EmailAddress";
config.AddCustomTransformation<Address, AddressDto>("Address", address =>
mapper.Map<Address, AddressDto>(address));
});
}
}
public class AddressMappingConfig : IMapperConfig
{
public void Configure(MapperService mapper)
{
mapper.Add<Address, AddressDto>();
}
}
To enable MiniMapr in your application, register your mapping configurations:
var services = new ServiceCollection();
services.AddMapper(mapper =>
{
mapper.Add<UserMappingConfig>()
.Add<AddressMappingConfig>();
});
var serviceProvider = services.BuildServiceProvider();
var mapperService = serviceProvider.GetRequiredService<IMapper>();
Once registered, you can use the mapper as follows:
var user = new User
{
Name = "Alice",
Email = "alice@email.com",
Password = "secret123",
Address = new Address { Street = "123 Maple St" }
};
var userDto = mapperService.Map<User, UserDto>(user);
Console.WriteLine(userDto.Name); // Alice
Console.WriteLine(userDto.EmailAddress); // alice@email.com
Console.WriteLine(userDto.Password); // (empty)
Console.WriteLine(userDto.Address.Street); // 123 Maple St
Introduction
Understand the philosophy, goals, and high-level overview of how MiniMapr works.
Getting Started
Learn how to install, configure, and use MiniMapr in your own projects.
API Reference Dive deep into the full API, including all public types, methods, and configuration options.
We welcome contributions of all kinds β whether youβre fixing bugs, adding features, writing documentation, or suggesting improvements.
To get started:
This project is licensed under the MIT License. You are free to use, modify, and distribute it as needed.
If you find MiniMapr useful, consider starring the repository β to support the project!