EasilyNET.ExpressMapper 3.24.1121.183

dotnet add package EasilyNET.ExpressMapper --version 3.24.1121.183
                    
NuGet\Install-Package EasilyNET.ExpressMapper -Version 3.24.1121.183
                    
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="EasilyNET.ExpressMapper" Version="3.24.1121.183" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasilyNET.ExpressMapper" Version="3.24.1121.183" />
                    
Directory.Packages.props
<PackageReference Include="EasilyNET.ExpressMapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EasilyNET.ExpressMapper --version 3.24.1121.183
                    
#r "nuget: EasilyNET.ExpressMapper, 3.24.1121.183"
                    
#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.
#addin nuget:?package=EasilyNET.ExpressMapper&version=3.24.1121.183
                    
Install EasilyNET.ExpressMapper as a Cake Addin
#tool nuget:?package=EasilyNET.ExpressMapper&version=3.24.1121.183
                    
Install EasilyNET.ExpressMapper as a Cake Tool

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 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.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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 275 5 months ago
3.24.1120.183 97 5 months ago
3.24.1119.31 100 5 months ago
3.24.1115.143 87 5 months ago
3.24.1113.100 103 5 months ago
3.24.1112.125 583 5 months ago
3.24.1107.140 105 5 months ago
3.24.1107.54 91 5 months ago
3.24.1107.34 106 5 months ago
3.24.1105.111 99 5 months ago
3.24.1103.31 110 5 months ago
3.24.1103 104 5 months ago
3.24.1031.135 118 5 months ago
3.24.1031.112 104 5 months ago
3.24.1031.104 91 5 months ago
3.24.1029.142 104 5 months ago
3.24.1025.30 197 5 months ago
3.24.1022.142 83 6 months ago
3.24.1018.204 149 6 months ago
3.24.1018.175 150 6 months ago
3.24.1018.166 140 6 months ago
3.24.1018.93 153 6 months ago
3.24.1017.42 99 6 months ago
3.24.1016.161 101 6 months ago
3.24.1015.231 96 6 months ago
3.24.1015.14 98 6 months ago
3.24.1012.114 108 6 months ago
3.24.1009.115 104 6 months ago
3.24.1008.160 99 6 months ago
3.24.1008.133 99 6 months ago
3.24.1007.185 98 6 months ago
3.24.1003.33 118 6 months ago
3.24.1002.162 116 6 months ago
3.24.929.143 235 6 months ago
3.24.929.141 105 6 months ago
3.24.929.131 103 6 months ago
3.24.929.122 105 6 months ago
3.24.926.184 114 6 months ago
3.24.926.182 103 6 months ago
3.24.926.175 106 6 months ago
3.24.924.160 149 7 months ago
3.24.924.133 129 7 months ago
3.24.924.124 111 7 months ago
3.24.924.10 108 7 months ago
3.24.924.1 103 7 months ago
3.24.923.234 103 7 months ago
3.24.923.232 110 7 months ago
3.24.923.155 132 7 months ago
3.24.919.92 138 7 months ago
3.24.914.125 274 7 months ago
3.24.914.115 117 7 months ago
3.24.914.111 119 7 months ago
3.24.911.95 116 7 months ago
3.24.908.215 103 7 months ago
3.24.904.200 115 7 months ago
3.24.828.163 290 7 months ago
3.24.820.173 129 8 months ago
3.24.820.172 142 8 months ago