Skip to content

A fast, fun and stimulating object to object Mapper

License

Notifications You must be signed in to change notification settings

tinsunchan/Mapster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapster Icon

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<Destination>();

Mapping to an existing object

You make the object, Mapster maps to the object.

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();
}

What's new in Mapster 4.0

  • Two ways mapping
  • Unflattening
  • Map & ignore by property path
  • MaxDepth
  • Map to constructor

Why Mapster?

Performance & Memory efficient

Mapster was designed to be efficient on both speed and memory. You could gain 5x faster while using only 1/3 of memory. And you could gain 13x faster with Mapster CodeGen!

Method Mean StdDev Error Gen 0 Gen 1 Gen 2 Allocated
'Mapster 4.1.1' 1,388,744.4 us 3,987.51 us 6,028.54 us 312000.0000 - - 1251.22 MB
'Mapster 4.1.1 (Codegen)' 505,727.6 us 2,525.21 us 3,817.75 us 312000.0000 - - 1251.22 MB
'ExpressMapper 1.9.1' 3,122,200.4 us 11,701.40 us 19,663.45 us 604000.0000 - - 2418.52 MB
'AutoMapper 9.0.0' 6,883,546.7 us 28,159.65 us 42,573.37 us 911000.0000 - - 3646.85 MB

Step into debugging

Step-into debugging lets you debug your mapping and inspect values as same as its your code. image

Code Generation NEW!!

Mapster CodeGen lets you do mapping with

  • Validate mapping at compile time
  • Getting raw performance
  • Seeing your mapping code & debugging
  • Finding usage of your models' properties

Change logs

https://github.com/MapsterMapper/Mapster/releases

Usages

https://github.com/MapsterMapper/Mapster/wiki

About

A fast, fun and stimulating object to object Mapper

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • C# 94.3%
  • PowerShell 5.6%
  • Batchfile 0.1%