Mapster 5.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Mapster --version 5.3.0
NuGet\Install-Package Mapster -Version 5.3.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mapster" Version="5.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mapster --version 5.3.0
#r "nuget: Mapster, 5.3.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mapster as a Cake Addin
#addin nuget:?package=Mapster&version=5.3.0

// Install Mapster as a Cake Tool
#tool nuget:?package=Mapster&version=5.3.0

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 5.0

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 to 12x faster with

|                    Method |      Mean | Allocated |
|-------------------------- | ---------:|----------:|
|           'Mapster 5.0.0' | 141.84 ms | 125.12 MB |
|  'Mapster 5.0.0 (Roslyn)' |  60.48 ms | 125.12 MB |
|     'Mapster 5.0.0 (FEC)' |  58.17 ms | 119.02 MB |
| 'Mapster 5.0.0 (Codegen)' |  51.56 ms | 125.12 MB |
|     'ExpressMapper 1.9.1' | 299.05 ms | 241.85 MB |
|        'AutoMapper 9.0.0' | 708.06 ms | 364.69 MB |
Step into debugging

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

Code Generation

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

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
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (316)

Showing the top 5 NuGet packages that depend on Mapster:

Package Downloads
Mapster.DependencyInjection

Dependency Injection supports for Mapster

Furion.Extras.ObjectMapper.Mapster

Furion 对象映射 Mapster 插件。

MPACKAGE.LibDomain

Package Description

Mapster.EFCore

EFCore plugin for Mapster

Indigina.Reactive

This NuGet package contains MediatR extensions for Indigina projects.

GitHub repositories (39)

Showing the top 5 popular GitHub repositories that depend on Mapster:

Repository Stars
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
fullstackhero/dotnet-webapi-starter-kit
production grade .net 8 webapi starter kit with multitenancy support and clean code. 🔥
MonkSoul/Furion
Make .NET development easier, more versatile, and more popular.
xunkong/xunkong
记录旅途中发生的事
meysamhadeli/booking-microservices
Practical microservices, built with .Net 8, DDD, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Version Downloads Last updated
7.4.1-pre01 58,554 9/22/2023
7.4.0 2,013,289 9/21/2023
7.4.0-pre06 129,895 2/26/2023
7.4.0-pre05 41,923 1/7/2023
7.4.0-pre04 5,963 1/3/2023
7.4.0-pre03 141,729 6/27/2022
7.4.0-pre02 20,396 4/5/2022
7.4.0-pre01 35,145 4/4/2022
7.3.0 9,451,723 2/20/2022
7.2.0 5,168,537 4/10/2021
7.1.5 652,629 2/24/2021
7.1.3 212,734 1/24/2021
7.0.1 434,165 11/26/2020
7.0.0 147,841 11/12/2020
6.5.1 279,658 10/23/2020
6.5.0 397,048 8/19/2020
6.1.1 49,515 8/6/2020
6.0.0 27,887 7/30/2020
5.3.2 350,194 5/29/2020
5.3.1 56,050 5/12/2020
5.3.0 148,457 4/10/2020
5.2.0 96,625 3/14/2020
5.1.0 47,140 3/3/2020
5.0.0 781,341 2/2/2020
4.1.1 600,346 10/19/2019
4.1.0 725,112 6/15/2019
4.0.0 287,471 4/13/2019
3.3.2 124,140 3/6/2019
3.3.1 86,314 2/5/2019
3.3.0 102,480 1/29/2019
3.2.0 430,747 9/9/2018
3.1.8 542,127 11/16/2017
3.1.7 2,751 11/11/2017
3.1.6 70,082 10/15/2017
3.1.5 13,072 10/9/2017
3.1.4 6,278 10/1/2017
3.1.3 40,504 8/22/2017
3.1.1 23,921 6/19/2017
3.1.0 6,621 6/11/2017
3.0.4 23,793 5/28/2017
2.6.1 53,300 12/8/2016
2.6.0 2,176 12/3/2016
2.5.0 73,184 8/7/2016
2.4.3 3,656 7/14/2016
2.4.2 2,153 7/4/2016
2.4.1 2,118 6/22/2016
2.4.0 2,045 6/18/2016
2.3.0 27,804 3/18/2016
2.1.2 7,341 2/15/2016
2.1.1 2,150 1/29/2016
2.1.0 2,244 1/25/2016
2.0.4 1,949 1/21/2016
2.0.3 1,966 1/20/2016
2.0.2 1,896 1/19/2016
2.0.1 1,919 1/19/2016
2.0.0 1,898 1/19/2016
1.14.0 20,584 3/4/2015
1.12.0 10,126 3/2/2015