Simple.AutoMapper 1.0.9

dotnet add package Simple.AutoMapper --version 1.0.9
                    
NuGet\Install-Package Simple.AutoMapper -Version 1.0.9
                    
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="Simple.AutoMapper" Version="1.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Simple.AutoMapper" Version="1.0.9" />
                    
Directory.Packages.props
<PackageReference Include="Simple.AutoMapper" />
                    
Project file
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 Simple.AutoMapper --version 1.0.9
                    
#r "nuget: Simple.AutoMapper, 1.0.9"
                    
#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 Simple.AutoMapper@1.0.9
                    
#: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=Simple.AutoMapper&version=1.0.9
                    
Install as a Cake Addin
#tool nuget:?package=Simple.AutoMapper&version=1.0.9
                    
Install as a Cake Tool

Simple.AutoMapper

NuGet .NET License Downloads

High-performance object mapping for .NET with expression tree compilation. Simple API, powerful configuration options.

v1.0.9 - Added Condition, NullSubstitute, BeforeMap/AfterMap, ConstructUsing. See Release Notes.

Installation

dotnet add package Simple.AutoMapper

Target Frameworks: netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0

Quick Start

using Simple.AutoMapper.Core;

// Simple mapping - no configuration needed
var dto = Mapper.Map<User, UserDto>(user);
var dtos = Mapper.Map<User, UserDto>(users);

// In-place update
Mapper.Map(source, existingDestination);

Configuration Options

Basic Configuration

// Configure mapping with options
Mapper.CreateMap<User, UserDto>()
    .Ignore(d => d.Password)
    .ReverseMap();  // Creates UserDto -> User mapping too

ForMember with MapFrom

Mapper.CreateMap<User, UserDto>()
    .ForMember(d => d.FullName, opt => opt.MapFrom(s => $"{s.FirstName} {s.LastName}"))
    .ForMember(d => d.Age, opt => opt.MapFrom(s => DateTime.Now.Year - s.BirthYear));

Condition - Conditional Mapping

Mapper.CreateMap<User, UserDto>()
    .ForMember(d => d.Email, opt => {
        opt.MapFrom(s => s.Email);
        opt.Condition(s => s.IsEmailVerified);  // Only map if condition is true
    });

NullSubstitute - Default Values

Mapper.CreateMap<User, UserDto>()
    .ForMember(d => d.DisplayName, opt => {
        opt.MapFrom(s => s.Nickname);
        opt.NullSubstitute("Anonymous");  // Use "Anonymous" if source is null
    });

BeforeMap / AfterMap - Callbacks

Mapper.CreateMap<User, UserDto>()
    .BeforeMap((src, dest) => {
        // Execute before property mapping
        dest.MappedAt = DateTime.UtcNow;
    })
    .AfterMap((src, dest) => {
        // Execute after property mapping
        dest.FullName = $"{dest.FirstName} {dest.LastName}";
    });

ConstructUsing - Custom Construction

// For types without parameterless constructor
Mapper.CreateMap<User, UserDto>()
    .ConstructUsing(src => new UserDto(src.Id));

// For immutable objects
Mapper.CreateMap<User, ImmutableUserDto>()
    .ConstructUsing(src => new ImmutableUserDto(
        src.Id,
        src.Name,
        src.Email
    ));

Circular Reference Handling

Mapper.CreateMap<Parent, ParentDto>()
    .PreserveReferences()  // Handle circular references
    .MaxDepth(5);          // Limit recursion depth

Dependency Injection

// In Program.cs or Startup.cs
services.AddSimpleMapper(cfg => {
    cfg.AddProfile<UserMappingProfile>();
});

// Or scan assemblies
services.AddSimpleMapper(typeof(UserMappingProfile).Assembly);

Creating Profiles

public class UserMappingProfile : Profile
{
    public UserMappingProfile()
    {
        CreateMap<User, UserDto>()
            .ForMember(d => d.FullName, opt => opt.MapFrom(s => $"{s.FirstName} {s.LastName}"));

        CreateMap<Address, AddressDto>();
    }
}

EF Core Integration

Read Operations

// Materialize first, then map
var users = await db.Users
    .AsNoTracking()
    .Include(u => u.Address)
    .ToListAsync();

var dtos = Mapper.Map<User, UserDto>(users);

Write Operations

// Create
var entity = Mapper.Map<CreateUserDto, User>(dto);
await db.Users.AddAsync(entity);

// Update in-place
var entity = await db.Users.FindAsync(id);
Mapper.Map(dto, entity);
await db.SaveChangesAsync();

Collection Sync

var result = Mapper.Map(
    dtoList,
    entityList,
    dto => dto.Id,
    entity => entity.Id,
    removeMissing: true
);
// result.Added, result.Updated, result.Removed

Type Support

Type Support
Simple types (int, string, DateTime, Guid, etc.)
Nullable types
Enums
Complex types (classes) ✅ Recursive
Collections (List, Array, IEnumerable)
Circular references ✅ With PreserveReferences()

Performance

  • Expression tree compilation for fast subsequent mappings
  • Thread-safe caching of compiled mappers
  • First mapping incurs compilation cost; subsequent calls are optimized

Samples & Tests

  • See samples/ for end-to-end usage examples
  • See tests/ for comprehensive test coverage including edge cases

License

MIT License - see LICENSE.md

Team

Core Development Team

  • SEONGAHN - Lead Developer & Project Architect
  • YUJIN - Senior Developer & Exchange Integration Specialist
  • SEJIN - Software Developer & API Implementation

Built with care by the ODINSOFT Team | GitHub

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.9 90 1/11/2026
1.0.8 184 10/27/2025
1.0.6 169 8/22/2025
1.0.5 176 8/21/2025
1.0.4 174 8/20/2025

v1.0.9
- Add ForMember Condition support for conditional property mapping
- Add ForMember NullSubstitute support for null value replacement
- Add BeforeMap/AfterMap callbacks for pre/post mapping logic
- Add ConstructUsing for custom object construction (immutable objects support)
- Increase test coverage from 63% to 87% (line coverage)
- Add comprehensive test suites for DI, Profile, MappingContext, TypePair, SyncResult
- Add net10.0 target framework support
- Fix PreserveReferences circular reference detection bug
- Fix net9.0 missing from DI support condition
- Add Mapper.Map<List<TDestination>>(entities) single type parameter support
- Upgrade Microsoft.Extensions.* packages to 10.0.1
- All existing v1.0.8 features remain compatible
- Targets: netstandard2.0, netstandard2.1, net8.0, net9.0, net10.0