LiteMapper 1.0.0

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

LiteMapper

A lightweight, zero-dependency object mapping library for .NET 8 that maps between DTOs, ViewModels, and Entities automatically.

Features

  • Zero Dependencies: No external dependencies
  • Convention-Based Mapping: Automatically maps properties with matching names (case-insensitive)
  • Custom Property Mapping: Fluent API for custom transformations
  • Collection Mapping: Built-in support for mapping collections
  • Type Conversion: Automatic type conversion for compatible types
  • Property Ignoring: Exclude specific properties from mapping
  • Thread-Safe: Uses concurrent dictionaries for caching
  • Performance: Caches reflection metadata for fast repeated mappings

Installation

dotnet add package LiteMapper

Quick Start

using LiteMapper;

// Create mapper instance
var mapper = new Mapper();

// Simple convention-based mapping
var userDto = mapper.Map<UserEntity, UserDto>(userEntity);

// Custom mapping configuration
mapper.CreateMap<UserEntity, UserDto>()
    .ForMember(dest => dest.FullName, src => $"{src.FirstName} {src.LastName}")
    .ForMember(dest => dest.Status, src => src.IsActive ? "Active" : "Inactive")
    .Ignore(dest => dest.Email);

// Map collections
var userDtos = mapper.Map<UserEntity, UserDto>(userEntities);

Usage Examples

Convention-Based Mapping

Properties with matching names are automatically mapped:

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
}

public class ProductDto
{
    public int Id { get; set; }
    public string Name { get; set; }
    public decimal Price { get; set; }
}

var mapper = new Mapper();
var productDto = mapper.Map<Product, ProductDto>(product);

Custom Property Mapping

Use ForMember to define custom mappings:

mapper.CreateMap<Product, ProductViewModel>()
    .ForMember(dest => dest.PriceFormatted, src => $"${src.Price:F2}")
    .ForMember(dest => dest.InStock, src => src.Stock > 0);

Ignoring Properties

Exclude properties from mapping:

mapper.CreateMap<User, UserDto>()
    .Ignore(dest => dest.PasswordHash);

Collection Mapping

Map collections of objects:

IEnumerable<Product> products = GetProducts();
var productDtos = mapper.Map<Product, ProductDto>(products);

Mapping to Existing Instance

Update an existing object:

var existingDto = new UserDto();
mapper.Map(userEntity, existingDto);

Performance Considerations

  • Property mappings are cached after first use
  • Reflection overhead is minimized through caching
  • Thread-safe implementation using ConcurrentDictionary
  • No runtime IL generation or compilation

Type Conversion

LiteMapper automatically handles:

  • Primitive type conversions
  • Nullable types
  • Enum conversions
  • String to enum parsing

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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.
  • net8.0

    • No dependencies.

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.0 248 10/29/2025

Initial release with convention-based mapping, custom property mapping, and collection support.