相同枚举 C# 之间的自动映射
AutoMapping between the Same Enum C#
我有这个映射枚举类型的自动映射器,
Mapper.CreateMap<SASEMProfileVm, SASEMMembersDto>()
.ForMember(dest => dest.ProfessionalHistoryDto.CarryingTime,
opt => opt.MapFrom(src => src.ProfessionalHistoryCarryingTime))
CarryingTime 属于 TimePeriod 类型,ProfessionalHistoryCarryingTime 也来自 TimePeriod 类型
当我 运行 它给了我这个错误
Expression 'dest => Convert(dest.ProfessionalHistoryDto.CarryingTime)'
must resolve to top-level member and not any child object's
properties. Use a custom resolver on the child type or the AfterMap
option instead. Parameter name: lambdaExpression
我应该怎么做才能解决?
Automapper 无法为多级对象定义映射。您可以使用 .AfterMap
Mapper.CreateMap<SASEMProfileVm, SASEMMembersDto>()
.AfterMap((s, d) =>
d.ProfessionalHistoryDto.CarryingTime = s.ProfessionalHistoryCarryingTime);
我有这个映射枚举类型的自动映射器,
Mapper.CreateMap<SASEMProfileVm, SASEMMembersDto>()
.ForMember(dest => dest.ProfessionalHistoryDto.CarryingTime,
opt => opt.MapFrom(src => src.ProfessionalHistoryCarryingTime))
CarryingTime 属于 TimePeriod 类型,ProfessionalHistoryCarryingTime 也来自 TimePeriod 类型
当我 运行 它给了我这个错误
Expression 'dest => Convert(dest.ProfessionalHistoryDto.CarryingTime)' must resolve to top-level member and not any child object's properties. Use a custom resolver on the child type or the AfterMap option instead. Parameter name: lambdaExpression
我应该怎么做才能解决?
Automapper 无法为多级对象定义映射。您可以使用 .AfterMap
Mapper.CreateMap<SASEMProfileVm, SASEMMembersDto>()
.AfterMap((s, d) =>
d.ProfessionalHistoryDto.CarryingTime = s.ProfessionalHistoryCarryingTime);