-
Notifications
You must be signed in to change notification settings - Fork 1
Core
Arnel Robles edited this page Sep 28, 2026
·
1 revision
using Mapsicle;
var dto = user.MapTo<UserDto>(); // Single object
List<UserDto> dtos = users.MapTo<UserDto>(); // Collection
var flat = order.MapTo<OrderFlatDto>(); // Auto-flatteningpublic class UserDto
{
[MapFrom("UserName")] // Map from different property
public string Name { get; set; }
[IgnoreMap] // Never mapped
public string Secret { get; set; }
}// Cycle Detection - no more StackOverflow
Mapper.MaxDepth = 32; // Default, configurable
// Validation at startup
Mapper.AssertMappingValid<User, UserDto>();
// Logging
Mapper.Logger = Console.WriteLine;
// Memory-bounded caching (prevents memory leaks in long-running apps)
Mapper.UseLruCache = true; // Enable LRU cache
Mapper.MaxCacheSize = 1000; // Limit cache entries
// Cache statistics
var stats = Mapper.CacheInfo();
Console.WriteLine($"Hit ratio: {stats.HitRatio:P1}");
// Scoped instances with isolated caches
using var mapper = MapperFactory.Create();
var dto = mapper.MapTo<UserDto>(user); // Uses isolated cacheMapsicle
Packages
- Core
- Fluent
- EntityFramework
- Validation
- NamingConventions
- Serilog
- Dapper
- AspNetCore
- Json
- Caching
- Audit
- DataAnnotations
Reference