Popularity
6.1
Growing
Activity
7.6
Growing
720
40
86

Description

A fast, fun and stimulating object to object Mapper

Programming language: C#
Latest version: v6.1.1

Mapster alternatives and similar packages

Based on the "Object to object mapping" category

Do you think we are missing an alternative of Mapster or a related project?

Add another 'Object to object mapping' Package

README

Mapster Icon

Mapster - The Mapper of Your Domain

Writing mapping method is machine job. Do not waste your time, let Mapster do it.

NuGet

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

Why Mapster?

Performance & Memory efficient

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

Method Mean StdDev Error Gen 0 Gen 1 Gen 2 Allocated
'Mapster 6.0.0' 108.59 ms 1.198 ms 1.811 ms 31000.0000 - - 124.36 MB
'Mapster 6.0.0 (Roslyn)' 38.45 ms 0.494 ms 0.830 ms 31142.8571 - - 124.36 MB
'Mapster 6.0.0 (FEC)' 37.03 ms 0.281 ms 0.472 ms 29642.8571 - - 118.26 MB
'Mapster 6.0.0 (Codegen)' 34.16 ms 0.209 ms 0.316 ms 31133.3333 - - 124.36 MB
'ExpressMapper 1.9.1' 205.78 ms 5.357 ms 8.098 ms 59000.0000 - - 236.51 MB
'AutoMapper 10.0.0' 420.97 ms 23.266 ms 35.174 ms 87000.0000 - - 350.95 MB

Step into debugging

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

Code Generation

Code generation lets you do mapping with

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

There are 2 tools, you can choose based on your preference.

Change logs

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

Usages

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

Acknowledgements

JetBrains kindly provides Mapster with a free open-source licence for their Resharper and Rider.

  • Resharper makes Visual Studio a much better IDE
  • Rider is fast & powerful cross platform .NET IDE

image