Mapster - The Mapper of Your Domain
Writing mapping method is machine job. Do not waste your time, let Mapster do it.
Get it
PM> Install-Package Mapster
Basic usage
Mapping to a new object
Mapster creates the destination object and maps values to it.
var destObject = sourceObject.Adapt<TDestination>();
Mapping to an existing object
You make the object, Mapster maps to the object.
TDestination destObject = new TDestination();
destObject = sourceObject.Adapt(destObject);
Queryable Extensions
Mapster also provides extensions to map queryables.
using (MyDbContext context = new MyDbContext())
{
// Build a Select Expression from DTO
var destinations = context.Sources.ProjectToType<Destination>().ToList();
// Versus creating by hand:
var destinations = context.Sources.Select(c => new Destination(){
Id = p.Id,
Name = p.Name,
Surname = p.Surname,
....
})
.ToList();
}
Performance
Don't let other libraries slow you down, Mapster is at least twice faster!
What's new in 3.0
Debugging generated mapping function!

Mapping your DTOs directly to EF6!
var poco = dto.BuildAdapter()
.CreateEntityFromContext(db)
.AdaptToType<DomainPoco>();
Change logs
https://github.com/MapsterMapper/Mapster/releases

