Brainy.Mapper
1.0.5
dotnet add package Brainy.Mapper --version 1.0.5
NuGet\Install-Package Brainy.Mapper -Version 1.0.5
<PackageReference Include="Brainy.Mapper" Version="1.0.5" />
<PackageVersion Include="Brainy.Mapper" Version="1.0.5" />
<PackageReference Include="Brainy.Mapper" />
paket add Brainy.Mapper --version 1.0.5
#r "nuget: Brainy.Mapper, 1.0.5"
#:package Brainy.Mapper@1.0.5
#addin nuget:?package=Brainy.Mapper&version=1.0.5
#tool nuget:?package=Brainy.Mapper&version=1.0.5
Brainy.Mapper
Brainy.Mapper is a lightweight and high-performance object mapping library for .NET 8, 9 & 10.
It was built to provide a clean, fast, and dependency-light alternative for mapping objects without unnecessary complexity. Whether you're mapping DTOs, entities, nested models, or query projections, Brainy.Mapper keeps the API simple while covering the features commonly required in real-world applications.
The library follows familiar mapping conventions, making it easy to adopt while remaining lightweight and fully open source.
Features
- ð Fast object-to-object mapping
- ðŊ Convention-based property mapping
- ð Custom member mapping with
ForMember() - ðĶ Nested object mapping
- ð Collection and array mapping
- ðģ Automatic property flattening
- ðŦ Ignore destination members
- âïļ Map onto existing objects
- ðĒ Automatic enum conversion
- ð LINQ
ProjectTo()support - ð Dependency Injection support
- ð§Đ Automatic mapping registration using
IMap<T> - ðĄïļ Null-safe projections
- âïļ Configurable mapping profiles
- ðŠķ Lightweight with minimal dependencies
- ð Free and open source
Why Brainy.Mapper?
Brainy.Mapper was created with one goal in mind:
Provide the mapping features developers actually use without adding unnecessary complexity.
Many mapping libraries have grown significantly over time, introducing features that aren't needed in every project or moving toward commercial licensing. Brainy.Mapper focuses on delivering the core mapping experience in a clean, maintainable, and developer-friendly way.
Whether you're building a small API, a Clean Architecture application, or a large enterprise solution, Brainy.Mapper helps reduce repetitive mapping code while keeping configuration straightforward and easy to understand.
Installation
Install the package from NuGet.
dotnet add package Brainy.Mapper
or
Install-Package Brainy.Mapper
Quick Start
Create a Profile
public class UserProfile : Profile
{
public UserProfile()
{
CreateMap<User, UserDto>()
.ForMember(
d => d.FullName,
opt => opt.MapFrom(s => s.FirstName + " " + s.LastName));
}
}
Configure the Mapper
var configuration = new MapperConfiguration(cfg =>
{
cfg.AddProfile<UserProfile>();
});
var mapper = configuration.CreateMapper();
Map Objects
UserDto dto = mapper.Map<UserDto>(user);
Dependency Injection
Brainy.Mapper includes built-in Dependency Injection support.
builder.Services.AddBrainyMapper(
Assembly.GetExecutingAssembly());
Then simply inject IMapper.
public class UserService
{
private readonly IMapper _mapper;
public UserService(IMapper mapper)
{
_mapper = mapper;
}
}
Automatic Mapping Registration
Brainy.Mapper can automatically discover mappings from your assembly using the IMap<T> interface.
public class UserMapping : IMap<User>
{
public void Mapping(Profile profile)
{
profile.CreateMap<User, UserDto>();
}
}
No manual registration of every mapping class is required.
Collection Mapping
List<UserDto> users =
mapper.Map<List<UserDto>>(entities);
Nested Object Mapping
public class Department
{
public string Name { get; set; }
}
public class Student
{
public Department Department { get; set; }
}
public class StudentDto
{
public DepartmentDto Department { get; set; }
}
Nested objects are mapped automatically when a mapping exists for both types.
Property Flattening
Brainy.Mapper automatically supports property flattening.
public class Student
{
public Department Department { get; set; }
}
public class StudentDto
{
public string DepartmentName { get; set; }
}
No additional configuration is required.
Custom Member Mapping
CreateMap<User, UserDto>()
.ForMember(
d => d.FullName,
opt => opt.MapFrom(
s => s.FirstName + " " + s.LastName));
Ignore Members
CreateMap<User, UserDto>()
.ForMember(
d => d.Password,
opt => opt.Ignore());
Mapping to Existing Objects
mapper.Map(updateRequest, existingEntity);
Useful for update operations where an existing entity should be modified instead of creating a new instance.
ProjectTo
Project directly from an IQueryable without materializing entities first.
var users = context.Users
.ProjectTo<UserDto>(mapper)
.ToList();
This allows only the required columns to be selected by the underlying query provider.
Roadmap
- â Object Mapping
- â Nested Object Mapping
- â Collection Mapping
- â Property Flattening
- â Custom Member Mapping
- â Ignore Members
- â Existing Object Mapping
- â Enum Conversion
- â Dependency Injection
- â Assembly Scanning
- â ProjectTo Support
- âģ Reverse Mapping
- âģ Constructor Mapping
- âģ Attribute-Based Mapping
Contributing
Contributions, bug reports, feature suggestions, and pull requests are always welcome.
If you find an issue or have an idea for improvement, feel free to open an issue on GitHub.
Author
Brainy.Mapper is created and maintained by Shakeel Iqbal, a Senior .NET Architect and C# Developer with extensive experience building enterprise applications and software solutions using the Microsoft technology stack.
- LinkedIn: Shakeel Iqbal
- Company: Brainy Solutions
If you find Brainy.Mapper useful, feel free to â star the repository, report issues, suggest improvements, or contribute through a pull request.
License
Brainy.Mapper is released under the MIT License.
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.