This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3827|Reply: 1

[Source] .NET/C# lightweight Mapster object mapping framework

[Copy link]
Posted on 7/23/2023 11:52:45 AM | | | |
Requirements: Generally, the mapping (conversion) between objects will use implicit (implicit), explicit (explicit) conversion, or use the third-party commonly used package "AutoMapper", there are many such object conversion frameworks or help classes on the Internet, Mapster is a simple to use, powerful, excellent performance object mapping framework, compared with AutoMapper, Mapster performs better in terms of speed and memory footprint, can be usedGet 4x the performance improvement when using only 1/3 of the memoryLitre.

Review:

C# Conversion Operators: implicit (implicit), explicit (display)
https://www.itsvse.com/thread-3284-1-1.html

VS2012 Solution to the error when installing AutoMapper in Nuget
https://www.itsvse.com/thread-3896-1-1.html

AutoMapper Conversion Tutorial Between Objects [Source Code]
https://www.itsvse.com/thread-3791-1-1.html

AutoMapper type conversion error solution
https://www.itsvse.com/thread-3790-1-1.html

GitHub address:The hyperlink login is visible.
Chinese Documentation:The hyperlink login is visible.

Mapster vs AutoMapper comparison

From the official Mapster test

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


Mapster is simple to use

Create a new test console application and use nuget to reference the Mapster package with the following command:




Create a new class A and B, and the test code is as follows:







(End)




Previous:Base64 encoded string composition (what characters are in Base64)
Next:.NET/C# uses Refit to request an enum parameter enum type error
 Landlord| Posted on 7/23/2023 11:56:54 AM |
Map to an existing object


Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com