简体   繁体   English

无法使用 Automapper 解决映射器问题

[英]Unable to resolve mapper issue using Automapper

I have two classes in my code except one data member everything is same.除了一个数据成员外,我的代码中有两个类,一切都相同。 But, not getting how to resolve this issue using Automapper.但是,不知道如何使用 Automapper 解决这个问题。 Can someone please throw some light on this.有人可以对此有所了解吗?

Class A{ public string Id; public List Values; };

Class B{ public string Id; public List Items; };

Class C{ public string Value; public string Name; public string Dept; };

CreateMap<A, B>(); - This is giving following error while doing unit test, Unmapped members were found. - 这在进行单元测试时出现以下错误,发现未映射的成员。 Review the types and members below.查看下面的类型和成员。 Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type添加自定义映射表达式,忽略,添加自定义解析器,或修改源/目标类型

Explicit AutoMapper Property Mapping显式 AutoMapper 属性映射

CreateMap<A,B>()
     .ForMember(dest => dest.Items,
     opt => opt.MapFrom(src => src.Values));

Reference 参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Automapper 和 xUnit 进行单元测试时,Mapper 已初始化问题 - Mapper already initialized issue when using Automapper and xUnit for unit testing 如何解决 - 无法使用Automapper将Generic.List强制转换为Linq.IQueryable? - How to resolve - unable to cast Generic.List to Linq.IQueryable using Automapper? 与linq映射功能相比,使用映射器(automapper)有什么好处 - what is the benefits of using mapper (automapper) over linq map function 使用 Moq 模拟 AutoMapper Mapper.Map 调用 - Mock AutoMapper Mapper.Map call using Moq 使用AutoMapper.Profile创建实例(非静态)映射器 - Using AutoMapper.Profile for creating an instance(non-static) mapper 无法使用 AutoMapper 4.2 和 Autofac 解析 AutoMapper.IMapper - Cannot resolve AutoMapper.IMapper using AutoMapper 4.2 with Autofac 自动映射器:使集合没有其映射器 - Automapper: Leave collections without their mapper Automapper - 继承映射器不与Construct一起使用 - Automapper - Inheritance mapper not working with Construct Automapper 错误说映射器未初始化 - Automapper error saying mapper not initialized 什么是等效于使用AutoMapper 7.0.1在CreateMap中使用“静态” Mapper.Map的“实例”? - What is the “instance” equivalent to using the “static” Mapper.Map inside CreateMap using AutoMapper 7.0.1?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM