MorphNGo 1.0.2
dotnet add package MorphNGo --version 1.0.2
NuGet\Install-Package MorphNGo -Version 1.0.2
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="MorphNGo" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MorphNGo" Version="1.0.2" />
<PackageReference Include="MorphNGo" />
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 MorphNGo --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MorphNGo, 1.0.2"
#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 MorphNGo@1.0.2
#: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=MorphNGo&version=1.0.2
#tool nuget:?package=MorphNGo&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MorphNGo
A simple .NET 10 library for mapping data between objects. No complex configurations, just straightforward transformations.
Install
Via NuGet Package Manager:
dotnet add package MorphNGo
Or via Package Manager Console:
Install-Package MorphNGo
Or search for MorphNGo on NuGet.org
Setup
In Program.cs:
builder.Services.AddMorphNGoMapper(cfg =>
{
cfg.CreateMap<User, UserDto>();
});
Use
[ApiController]
[Route("api/users")]
public class UsersController : ControllerBase
{
private readonly IMapper _mapper;
public UsersController(IMapper mapper) => _mapper = mapper;
[HttpGet("{id}")]
public IActionResult GetUser(int id)
{
var user = _userService.GetUser(id);
return Ok(_mapper.Map<UserDto>(user));
}
}
What It Does
Before:
var dto = new UserDto
{
Id = user.Id,
FirstName = user.FirstName,
LastName = user.LastName,
Email = user.EmailAddress
};
After:
var dto = mapper.Map<UserDto>(user);
Features
- Automatic property mapping (same-name properties)
- Custom mapping with
ForMember() - Property renaming with
From() - Property ignoring with
Ignore() - Nested objects and collections
- Conditional mapping with
When() - Value transformers
- Full DI integration
- Runtime parameters: pass
params object[]toMap/MapTo/MapCollection, and useMapFrom((src, parameters) => …)to read lookups or options per call (see Runtime parameters guide)
Configuration Examples
Custom Property Mapping
cfg.CreateMap<User, UserDto>(map =>
{
map.ForMember(dest => dest.Email,
opt => opt.MapFrom(src => src.EmailAddress));
});
Ignore Properties
cfg.CreateMap<User, UserDto>(map =>
{
map.Ignore(dest => dest.Password);
});
Conditional Mapping
cfg.CreateMap<Order, OrderDto>(map =>
{
map.ForMember(d => d.Discount, opt =>
opt.When(src => src.Total > 100)
.MapFrom(src => src.Total * 0.1m));
});
Bidirectional Mapping with ReverseMap
Define a mapping in one direction and automatically create the reverse mapping:
cfg.CreateMap<User, UserDto>(map =>
{
map.ForMember(dest => dest.Email,
opt => opt.From("EmailAddress")); // Simple property rename
map.Ignore(dest => dest.Password);
map.ReverseMap(); // Automatically creates UserDto -> User mapping
});
// Now you can map in both directions:
var dto = mapper.Map<UserDto>(user); // User -> UserDto
var user = mapper.Map<User>(dto); // UserDto -> User
The reverse mapping automatically:
- ✅ Reverses simple property renames (
From()mappings) - ✅ Preserves ignored properties (excluded in both directions)
- ✅ Copies value transformers (applied in both directions)
- ℹ️ Skips complex mappings (
MapFrom()with custom functions only apply forward)
Example with property rename reversal:
cfg.CreateMap<Person, PersonDto>(map =>
{
// Forward: Person.FirstName -> PersonDto.FirstName
// Reverse: PersonDto.FirstName -> Person.FirstName (automatic!)
map.ForMember(dest => dest.FirstName,
opt => opt.From("FirstName"));
// Forward: Person.LastName -> PersonDto.FullName (custom function - forward only)
// Reverse: Uses automatic property matching
map.ForMember(dest => dest.FullName,
opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"));
map.ReverseMap();
});
Lifetime Options
// Singleton (recommended for most cases)
builder.Services.AddMorphNGoMapper(cfg => { }, ServiceLifetime.Singleton);
// Scoped (new per HTTP request)
builder.Services.AddMorphNGoMapper(cfg => { }, ServiceLifetime.Scoped);
// Transient (new every time)
builder.Services.AddMorphNGoMapper(cfg => { }, ServiceLifetime.Transient);
Documentation
- Quick Start Guide
- Complete User Guide
- Code Examples — includes parameterized mapping (examples 15–16)
Tests
53 tests. Run with:
dotnet test
License
Apache 2.0. See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
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 |
|---|---|---|
| 1.0.2 | 111 | 4/4/2026 |
| 1.0.2-beta | 94 | 4/4/2026 |
| 1.0.1 | 101 | 4/3/2026 |
| 1.0.1-beta | 89 | 4/3/2026 |