LiteMapper 1.0.0
dotnet add package LiteMapper --version 1.0.0
NuGet\Install-Package LiteMapper -Version 1.0.0
<PackageReference Include="LiteMapper" Version="1.0.0" />
<PackageVersion Include="LiteMapper" Version="1.0.0" />
<PackageReference Include="LiteMapper" />
paket add LiteMapper --version 1.0.0
#r "nuget: LiteMapper, 1.0.0"
#:package LiteMapper@1.0.0
#addin nuget:?package=LiteMapper&version=1.0.0
#tool nuget:?package=LiteMapper&version=1.0.0
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 | Versions 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. |
-
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.