Azka.ObjectMapper
10.0.0-alpha5
This is a prerelease version of Azka.ObjectMapper.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Azka.ObjectMapper --version 10.0.0-alpha5
NuGet\Install-Package Azka.ObjectMapper -Version 10.0.0-alpha5
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="Azka.ObjectMapper" Version="10.0.0-alpha5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Azka.ObjectMapper" Version="10.0.0-alpha5" />
<PackageReference Include="Azka.ObjectMapper" />
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 Azka.ObjectMapper --version 10.0.0-alpha5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Azka.ObjectMapper, 10.0.0-alpha5"
#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 Azka.ObjectMapper@10.0.0-alpha5
#: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=Azka.ObjectMapper&version=10.0.0-alpha5&prerelease
#tool nuget:?package=Azka.ObjectMapper&version=10.0.0-alpha5&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Azka.ObjectMapper
Azka.ObjectMapper is a lightweight object mapping library for .NET, designed to map data between classes (for example, Entity to DTO) using profile-based configuration.
Features
- Object mapping
TSource -> TDestination. - Collection mapping
IEnumerable<TSource> -> IEnumerable<TDestination>. - Custom member mapping with
ForMember(...). - Ignore source members with
Ignore(...). - Nested object mapping support (when profiles exist).
- Nested collection mapping support.
- Integration with
Microsoft.Extensions.DependencyInjection.
Installation
dotnet add package Azka.ObjectMapper
Quick Start
1. Create models
public class User
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
}
public class UserDto
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public long CreatedAtUnix { get; set; }
}
2. Create a mapping profile
using Azka.ObjectMapper;
public class UserMapProfile : ObjectMapProfile
{
public UserMapProfile()
{
CreateMap<User, UserDto>()
.ForMember(dest => dest.CreatedAtUnix, src =>
new DateTimeOffset(src.CreatedAt).ToUnixTimeSeconds());
}
}
3. Register in DI
Option A - register a profile instance:
using Azka.ObjectMapper;
builder.Services.AddObjectMapper(new UserMapProfile());
Option B - scan profiles from assembly:
using System.Reflection;
using Azka.ObjectMapper;
builder.Services.AddObjectMapper(Assembly.GetExecutingAssembly());
4. Use in service/controller
using Azka.ObjectMapper;
public class UsersService
{
private readonly IObjectMapper _mapper;
public UsersService(IObjectMapper mapper)
{
_mapper = mapper;
}
public UserDto GetDto(User user)
{
return _mapper.Map<User, UserDto>(user);
}
public IEnumerable<UserDto> GetDtos(IEnumerable<User> users)
{
return _mapper.Map<User, UserDto>(users);
}
}
Mapping Configuration
ForMember (custom destination member)
CreateMap<User, UserDto>()
.ForMember(dest => dest.Name, src => $"[USER] {src.Name}");
Ignore (ignore source member)
CreateMap<User, UserDto>()
.Ignore(src => src.Email);
Nested Mapping
If a property is a complex object or a collection of complex objects, profiles for child types must also be available.
public class Address
{
public string City { get; set; } = string.Empty;
}
public class AddressDto
{
public string City { get; set; } = string.Empty;
}
public class User
{
public Address Address { get; set; } = new();
}
public class UserDto
{
public AddressDto Address { get; set; } = new();
}
public class UserMapProfile : ObjectMapProfile
{
public UserMapProfile()
{
CreateMap<Address, AddressDto>();
CreateMap<User, UserDto>();
}
}
API Summary
IObjectMapper.Map<T, U>(T obj)maps a single object to destination type.IObjectMapper.Map<T, U>(IEnumerable<T> listOfObjects)maps an object collection to destination collection type.MapProfile<T, U>.ForMember(...)defines custom mapping for a destination member.MapProfile<T, U>.Ignore(...)ignores a source member.
Important Notes
- Destination type must have a default constructor.
- Mapping only works when a
CreateMap<T, U>()profile exists. - For nested types, nested profiles are also required.
- If a mapping profile is not found, mapper throws
InvalidOperationException.
Requirements
- .NET 10.0 or later
- Microsoft.Extensions.DependencyInjection 10.0.2 or later
License
See LICENSE.txt.
Links
| 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.2)
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 |
|---|---|---|
| 10.0.0-rc.4 | 50 | 11/9/2026 |
| 10.0.0-rc.3 | 70 | 11/7/2026 |
| 10.0.0-rc.2 | 67 | 10/27/2026 |
| 10.0.0-rc.1 | 116 | 6/30/2026 |
| 10.0.0-alpha6 | 92 | 6/20/2026 |
| 10.0.0-alpha5 | 102 | 3/16/2026 |
| 10.0.0-alpha.9 | 91 | 6/25/2026 |
| 10.0.0-alpha.8 | 90 | 6/25/2026 |
| 10.0.0-alpha.7 | 99 | 6/25/2026 |
Initial release of Azka.ObjectMapper
- Object Mapper