Installation
Install via NuGet Package Manager:
Install-Package ExIgniter.ObjectMapper
Or via .NET CLI:
dotnet add package ExIgniter.ObjectMapper
The intelligent, high-performance object mapper for .NET
ExIgniter.ObjectMapper 2.0 is a complete redesign of our popular object mapping library, offering:
Install via NuGet Package Manager:
Install-Package ExIgniter.ObjectMapper
Or via .NET CLI:
dotnet add package ExIgniter.ObjectMapper
Simple object mapping:
// Basic mapping
var userDto = userEntity.MapTo<UserDto>();
// Collection mapping
List<UserDto> dtos = entities.MapAllTo<UserDto>().ToList();
TResult MapTo<TResult>()
Maps the source object to a new instance of the specified type.
Parameters: None
Returns: New instance of TResult
var dto = entity.MapTo<UserDto>();
TResult MapTo<TResult>(MapConfig config)
Maps with custom configuration.
Parameters:
config: MapConfig instancevar config = new MapConfig()
.Ignore(x => x.PasswordHash);
var dto = entity.MapTo<UserDto>(config);
Configuration options for mapping behavior.
| Method | Description |
|---|---|
Ignore<T>(Expression<Func<T, object>> expr) |
Ignores specified property |
MapAs<TSource, TDest>(Func<TSource, TDest> converter) |
Custom type converter |
WithNullHandling(NullHandlingStrategy strategy) |
Sets null handling behavior |
| Attribute | Description |
|---|---|
[MapIgnore] |
Excludes property from mapping |
[MapAs("PropertyName")] |
Maps to different target property |
[MapConstructor] |
Marks constructor for auto-mapping |
Note: While v2.0 maintains backward compatibility, these changes might affect edge cases.
Map<T>() is now MapTo<T>() (old version still supported)IEnumerable<T> instead of concrete ListThe following v1.x features are deprecated but still functional:
FasterMap() - Use MapTo() with performance configComplexMap() - Use MapTo() with deep mapping configFor maximum performance:
// Reuse config instances
var config = new MapConfig()
.WithNullHandling(NullHandlingStrategy.UseDefaultValue)
.CacheMappings(); // Enable type cache
// For hot paths
var fastMapper = config.CreateMapper<Source, Dest>();
var result = fastMapper.Map(source);
Implement complex transformations:
var config = new MapConfig()
.MapAs<DateTime, string>(d => d.ToString("yyyy-MM-dd"))
.MapAs<Address, string>(a => $"{a.Street}, {a.City}");
var result = source.MapTo<Destination>(config);