CreateMap<TempBranchActivity, BranchActivityOutput>() .ConstructUsing((src, ctx) => ctx.Mapper.Map<BranchActivityOutput>(src.BranchActivityInfo)) .ForMember(m => m.ApplyNum, opt => opt.MapFrom(m => m.BranchActivityApplyDto.ApplyNum));
用automapper ContructUsing 构造器。返回一个目标实例
这里就可以进行map .
以上方法可以写成
CreateMap<TempBranchActivity, BranchActivityOutput>() .ConstructUsing((src, ctx) => ctx.Mapper.Map<BranchActivityOutput>(ctx.Mapper.Map<BranchActivityOutput>(src.BranchActivityInfo)));