我有A类和B类:
#include <ostream>
std::ostream& operator<<(std::ostream &os, const Node &node) {
return os << "Node(" <<node.data << ")";
}
我正在尝试将列表映射到列表:
CreateMap
结果:
期望的结果应该是从枚举列表到字符串列表的成功映射,例如:class A
{
public List<TypeEnum> Types { get; set; }
...
}
class B
{
public List<string> TypesString { get; set; }
...
}
我该怎么做?
答案 0 :(得分:2)
尝试以下映射配置:
CreateMap<ClassA, CLassB>().ForMember(destination => destination.TypesString,
opt => opt.MapFrom(s => s.Types.Select(x => ((byte)x))));