EasilyNET.ExpressMapper
3.24.1016.161
See the version list below for details.
dotnet add package EasilyNET.ExpressMapper --version 3.24.1016.161
NuGet\Install-Package EasilyNET.ExpressMapper -Version 3.24.1016.161
<PackageReference Include="EasilyNET.ExpressMapper" Version="3.24.1016.161" />
paket add EasilyNET.ExpressMapper --version 3.24.1016.161
#r "nuget: EasilyNET.ExpressMapper, 3.24.1016.161"
// Install EasilyNET.ExpressMapper as a Cake Addin #addin nuget:?package=EasilyNET.ExpressMapper&version=3.24.1016.161 // Install EasilyNET.ExpressMapper as a Cake Tool #tool nuget:?package=EasilyNET.ExpressMapper&version=3.24.1016.161
EasilyNET.ExpressMapper
本项目从 RosTransNadzor/ExpressMapper 复刻,原项目好像没有 Nuget 包,所以自己复制代码到这里,并且发布到 Nuget 上.添加了注释以及修改了部分拼写错误的代码.
ExpressMapper
ExpressMapper 是一个轻量级且易于使用的对象到对象映射库,适用于 .NET,旨在简化在应用程序的各个层之间转换数据的过程.它提供了可自定义的映射配置、属性忽略、构造函数映射和复合配置,以轻松处理复杂的场景.
<details> <summary style="font-size: 14px">English</summary>
ExpressMapper is a lightweight and easy-to-use object-to-object mapping library for .NET, designed to streamline the process of transforming data between various layers of your application. It offers customizable mapping configurations, property ignoring, constructor mapping, and composite configurations to handle complex scenarios with ease.
</details>
Features | 特性
- 可自定义的映射配置: 通过细粒度控制定义源属性和目标属性之间的映射.
- 忽略特定属性: 在映射过程中选择忽略源或目标端的属性.
- 构造函数映射: 在实例化目标对象时使用特定的构造函数,适用于复杂对象.
- 复合配置: 在单个配置类中管理不同类型的多个映射.
<details> <summary style="font-size: 14px">English</summary>
- Customizable Mapping Configurations: Define mappings between source and destination properties with fine-grained control.
- Ignore Specific Properties: Choose to ignore properties on either the source or destination side during the mapping.
- Constructor Mapping: Use specific constructors when instantiating destination objects, useful for complex objects.
- Composite Configurations: Manage multiple mappings for different types within a single configuration class.
</details>
Installation | 安装
Install ExpressMapper via NuGet:
Install-Package EasilyNET.ExpressMapper
Getting Started | 入门
要使用 ExpressMapper,首先定义源类和目标类,然后使用提供的配置类配置映射.
<details> <summary style="font-size: 14px">English</summary>
To use ExpressMapper, start by defining your source and destination classes, and then configure the mappings using the provided configuration classes.
</details>
Example Classes | 示例类
public class User
{
public string Name { get; set; }
public string Description { get; set; }
}
public class UserDto
{
public string UserName { get; set; }
public string AdditionalInfo { get; set; }
}
Customizable Mapping Configurations | 可自定义的映射配置
定义不同类之间的属性映射方式:
<details> <summary style="font-size: 14px">English</summary>
Define how properties are mapped between different classes:
</details>
file class UserConfig : MapperConfig<User, UserDto>
{
public override void Configure(IMappingConfigurer<User, UserDto> configurer)
{
configurer
.Map(dto => dto.UserName, us => us.Name);
}
}
Ignoring Properties | 忽略属性
在映射过程中排除某些属性:
<details> <summary style="font-size: 14px">English</summary>
Exclude certain properties from the mapping process:
</details>
file class UserConfig : MapperConfig<User, UserDto>
{
public override void Configure(IMappingConfigurer<User, UserDto> configurer)
{
configurer
.Map(dto => dto.UserName, us => us.Name)
.IgnoreDest(dto => dto.UserName)
.IgnoreSource(us => us.Description);
}
}
Constructor Mapping | 构造函数映射
指定使用带有特定参数的构造函数:
<details> <summary style="font-size: 14px">English</summary>
Specify the use of constructors with specific parameters:
</details>
configurer.WithConstructor<string, string>();
Composite Configurations | 复合配置
将多个配置组合到一个配置类中:
<details> <summary style="font-size: 14px">English</summary>
Combine multiple configurations into a single configuration class:
</details>
file class GeneralConfig : CompositeConfig
{
public override void Configure()
{
NewConfiguration<Address, AddressDto>()
.IgnoreDest(dto => dto.City);
NewConfiguration<Product, ProductDto>()
.Map(dto => dto.Id, product => product.ProductId);
}
}
Example Usage | 示例用法
public static class Program
{
static void Main(string[] args)
{
var mapper = Mapper.Create<GeneralConfig, UserConfig>();
var user = new User
{
Description = "desc"
};
var dto = mapper.Map<User, UserDto>(user);
Console.WriteLine(dto);
}
}
这个示例演示了如何创建一个包含组合配置的映射器,并将 User 对象映射到 UserDto.
<details> <summary style="font-size: 14px">English</summary>
This example demonstrates how to create a mapper with combined configurations and map a User
object to a UserDto
.
</details>
Conclusion | 结论
ExpressMapper 为 .NET 应用程序中的对象到对象映射提供了一个灵活且强大的解决方案.无论是简单的 DTO 还是复杂的对象,都可以根据您的具体需求自定义映射.
<details> <summary style="font-size: 14px">English</summary>
ExpressMapper provides a flexible and powerful solution for object-to-object mapping in .NET applications. Customize your mappings to fit your specific needs, whether it's for simple DTOs or complex objects.
For more information, please refer to the official documentation or check out the source code examples.
</details>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. |
-
net8.0
- No dependencies.
-
net9.0
- 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 |
---|---|---|
3.24.1121.183 | 74 | 11/21/2024 |
3.24.1120.183 | 68 | 11/20/2024 |
3.24.1119.31 | 72 | 11/18/2024 |
3.24.1115.143 | 61 | 11/15/2024 |
3.24.1113.100 | 71 | 11/13/2024 |
3.24.1112.125 | 137 | 11/12/2024 |
3.24.1107.140 | 80 | 11/7/2024 |
3.24.1107.54 | 64 | 11/7/2024 |
3.24.1107.34 | 71 | 11/7/2024 |
3.24.1105.111 | 75 | 11/5/2024 |
3.24.1103.31 | 84 | 11/2/2024 |
3.24.1103 | 77 | 11/2/2024 |
3.24.1031.135 | 86 | 10/31/2024 |
3.24.1031.112 | 77 | 10/31/2024 |
3.24.1031.104 | 68 | 10/31/2024 |
3.24.1029.142 | 81 | 10/29/2024 |
3.24.1025.30 | 177 | 10/24/2024 |
3.24.1022.142 | 60 | 10/22/2024 |
3.24.1018.204 | 129 | 10/18/2024 |
3.24.1018.175 | 131 | 10/18/2024 |
3.24.1018.166 | 123 | 10/18/2024 |
3.24.1018.93 | 134 | 10/18/2024 |
3.24.1017.42 | 82 | 10/16/2024 |
3.24.1016.161 | 84 | 10/16/2024 |
3.24.1015.231 | 76 | 10/15/2024 |
3.24.1015.14 | 81 | 10/14/2024 |
3.24.1012.114 | 89 | 10/12/2024 |
3.24.1009.115 | 86 | 10/9/2024 |
3.24.1008.160 | 80 | 10/8/2024 |
3.24.1008.133 | 77 | 10/8/2024 |
3.24.1007.185 | 81 | 10/7/2024 |
3.24.1003.33 | 93 | 10/2/2024 |
3.24.1002.162 | 98 | 10/2/2024 |
3.24.929.143 | 216 | 9/29/2024 |
3.24.929.141 | 86 | 9/29/2024 |
3.24.929.131 | 85 | 9/29/2024 |
3.24.929.122 | 89 | 9/29/2024 |
3.24.926.184 | 90 | 9/26/2024 |
3.24.926.182 | 84 | 9/26/2024 |
3.24.926.175 | 84 | 9/26/2024 |
3.24.924.160 | 127 | 9/24/2024 |
3.24.924.133 | 108 | 9/24/2024 |
3.24.924.124 | 91 | 9/24/2024 |
3.24.924.10 | 91 | 9/23/2024 |
3.24.924.1 | 85 | 9/23/2024 |
3.24.923.234 | 84 | 9/23/2024 |
3.24.923.232 | 92 | 9/23/2024 |
3.24.923.155 | 109 | 9/23/2024 |
3.24.919.92 | 124 | 9/19/2024 |
3.24.914.125 | 258 | 9/14/2024 |
3.24.914.115 | 102 | 9/14/2024 |
3.24.914.111 | 106 | 9/14/2024 |
3.24.911.95 | 104 | 9/11/2024 |
3.24.908.215 | 89 | 9/8/2024 |
3.24.904.200 | 100 | 9/4/2024 |
3.24.828.163 | 275 | 8/28/2024 |
3.24.820.173 | 115 | 8/20/2024 |
3.24.820.172 | 121 | 8/20/2024 |