AutoMapperLite 2.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package AutoMapperLite --version 2.0.6
                    
NuGet\Install-Package AutoMapperLite -Version 2.0.6
                    
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="AutoMapperLite" Version="2.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoMapperLite" Version="2.0.6" />
                    
Directory.Packages.props
<PackageReference Include="AutoMapperLite" />
                    
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 AutoMapperLite --version 2.0.6
                    
#r "nuget: AutoMapperLite, 2.0.6"
                    
#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 AutoMapperLite@2.0.6
                    
#: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=AutoMapperLite&version=2.0.6
                    
Install as a Cake Addin
#tool nuget:?package=AutoMapperLite&version=2.0.6
                    
Install as a Cake Tool

AutoMapperLite

A lightweight and convention-friendly object-to-object mapper for .NET, inspired by AutoMapper — but simplified for small to medium projects and high control over mapping behavior.


🚀 Features

  • Simple and clean API
  • Supports .ForMember and .ForPath
  • Auto mapping for matching property names
  • Nested object mapping
  • Collection mapping (e.g., List<T>)
  • Profile-based mapping organization
  • Dependency Injection (DI) ready

📦 Installation

1. Install from NuGet Package

To install via NuGet, run the following command:

dotnet add package AutoMapperLite --version 2.0.4

2. Register AutoMapperLite in Program.cs

using AutoMapperLite;

builder.Services.AddAutoMapperLite(Assembly.GetExecutingAssembly());

3. Define your models

public class User
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Department Department { get; set; }
}

public class Department
{
    public string Name { get; set; }
}

4. Define your view model

public class UserViewModel
{
    public string FullName { get; set; }
    public DepartmentViewModel DepartmentViewModel { get; set; }
}

public class DepartmentViewModel
{
    public string DepartmentName { get; set; }
}

5. Create a mapping profile

public class MappingProfile : Profile
{
    public override void Configure(IMapperConfig config)
    {
        config.CreateMap<User, UserViewModel>()
              .ForMember(dest => dest.FullName, src => src.FirstName + " " + src.LastName)
              .ForPath("DepartmentViewModel.DepartmentName", src => src.Department.Name);
    }
}

6. Inject and use IMapper

[ApiController]
[Route("api/[controller]")]
public class UsersController : ControllerBase
{
    private readonly IMapper _mapper;

    public UsersController(IMapper mapper)
    {
        _mapper = mapper;
    }

    [HttpGet]
    public IActionResult Get()
    {
        var users = new List<User> {
            new User {
                FirstName = "John",
                LastName = "Doe",
                Department = new Department { Name = "IT" }
            }
        };

        var result = _mapper.Map<List<UserViewModel>>(users);
        return Ok(result);
    }
}
Product 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 was computed.  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 was computed.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

• Added ForPath and ForMember support
• Improved collection mapping (List<T>)
• Simplified usage with Map<TDestination>(TSource) format
• Support for nested property mapping and configuration profiles
• Refactored internal Mapper logic and added DI support