MapperToolkit 1.0.2.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MapperToolkit --version 1.0.2.1
NuGet\Install-Package MapperToolkit -Version 1.0.2.1
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="MapperToolkit" Version="1.0.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MapperToolkit --version 1.0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MapperToolkit, 1.0.2.1"
#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 MapperToolkit as a Cake Addin #addin nuget:?package=MapperToolkit&version=1.0.2.1 // Install MapperToolkit as a Cake Tool #tool nuget:?package=MapperToolkit&version=1.0.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MapperToolkit
This project is a Mapper library use Source Generator with function such as:
- mapper: object-object mapper .
- transoform:by object (entity) build specified model (DTO) .
MapperToolkit is the fastest .NET object mapper if member inclube List IEnumerable surpassing even the manual mapping and Mapperly The benchmark was generated with(https://github.com/GaoNian-NET/Benchmark.netCoreMappers).
Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Allocated |
---|---|---|---|---|---|---|
AgileMapper | 2,832.5 ns | 56.29 ns | 80.73 ns | 0.5035 | 0.0038 | 3 KB |
TinyMapper | 3,195.5 ns | 62.88 ns | 113.39 ns | 0.3853 | - | 2 KB |
ExpressMapper | 2,957.5 ns | 84.74 ns | 248.54 ns | 0.8049 | 0.0038 | 5 KB |
AutoMapper | 1,497.6 ns | 33.87 ns | 98.79 ns | 0.3452 | 0.0019 | 2 KB |
ManualMapping | 459.0 ns | 14.02 ns | 41.13 ns | 0.2103 | 0.0005 | 1 KB |
Mapster | 465.3 ns | 13.84 ns | 40.60 ns | 0.3285 | 0.0019 | 2 KB |
Mapperly | 484.8 ns | 9.02 ns | 16.71 ns | 0.2613 | 0.0010 | 2 KB |
MapperToolkit | 303.2 ns | 6.11 ns | 5.10 ns | 0.1884 | 0.0005 | 1 KB |
Quickstart
Installation
Add the NuGet Package to your project:
dotnet add package MapperToolkit
Create your first mapper
//example Entity
public class Entity
{
public string Account { get; set; }
public DateTime CreateTime { get; set; }
}
//example DTO
public class DTO
{
public string EmpNo { get; set; }
public string EmpName { get; set; }
public DateTime CreateTime { get; set; }
}
Create profile class inherit MapperToolkit.Profile in constructors type mapper code
// Profile declaration
public class MappingProfile : Profile
{
public MappingProfile()
{
GenerateAllMapper<Entity, DTO>()
.Map(src => src.Account[0..4],dest=>dest.EmpNo)
.Map(src => src.Account[4..^0],dest=>dest.EmpName);
}
}
//Generator code
public static partial class DTOMapper
{
public static global::ConsoleApp.DTO MapperToDTO(this global::ConsoleApp.Entity source)
{
global::ConsoleApp4.DTO result = new();
global::System.Func<global::ConsoleApp.Entity, string> EmpNoMapper = src => src.Account[0..4];
global::System.Func<global::ConsoleApp.Entity, string> EmpNameMapper = src => src.Account[4..^0];
result.EmpNo = EmpNoMapper.Invoke(source);
result.EmpName = EmpNameMapper.Invoke(source);
result.CreateTime = source.CreateTime;
return result;
}
}
//Mapper usage
var entity = new Entity() { Account = "A123Bojack" ,CreateTime = DateTime.Now };
var dto = entity.MapperToDTO();
Console.WriteLine($"EmpNo:{dto.EmpNo};EmpName:{dto.EmpName};CreateTime:{dto.CreateTime}");
// print EmpNo:A123;EmpName:Bojack;CreateTime:2022/8/16 12:13:15
Product | Versions 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 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.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.2.2 | 438 | 9/1/2022 |
1.0.2.1 | 387 | 9/1/2022 |
1.0.2 | 394 | 9/1/2022 |
1.0.1.9-alpha | 156 | 8/18/2022 |
1.0.1.8-alpha | 145 | 8/17/2022 |
1.0.1.7-alpha | 148 | 8/16/2022 |
1.0.1.6-alpha | 140 | 8/16/2022 |
1.0.1.5-alpha | 148 | 8/16/2022 |
1.0.1.4-alpha | 146 | 8/16/2022 |
1.0.1.3-alpha | 151 | 8/16/2022 |
1.0.1.2-alpha | 155 | 8/15/2022 |
1.0.1.1-alpha | 154 | 8/15/2022 |
1.0.1-alpha | 147 | 8/15/2022 |
1.0.0-alpha | 159 | 8/15/2022 |