0

A breakpoint in the following code in line resContext.Mapper... does stop the execution

CreateMap<MedicationFactory.Definition, TimeDescription>()
    .IgnoreAllUnmapped()
    .AfterMap((adapter, description, resContext) =>
    {
        resContext.Mapper.Map<MedicationTimePattern, TimeDescription>(adapter.TimePattern, description);
    })

I assume next this map should be called, but that seems not to be the case. A breakpoint here in the line resContext.Mapper is never hit. Is there an obvious reason?

CreateMap<MedicationTimePattern, TimeDescription>()
    .IgnoreAllUnmapped()
    .ForMember(dst => dst.ExtendedRRules, 
        src => 
        src.MapFrom((source, destination, member, resContext) =>
        {
            return resContext.Mapper.Map<ExtendedRRule[]>(source.ClassicDosage.ToRRule().ToArray());
        }))

Already tried https://docs.automapper.org/en/stable/Understanding-your-mapping.html but that did not really help.

manon
  • 252
  • 2
  • 9
  • A repro would help. Make a [gist](https://gist.github.com/lbargaoanu/9c7233441c3a3413cc2b9b9ebb5964a9) that we can execute and see fail. Without `IgnoreAllUnmapped`. – Lucian Bargaoanu Sep 29 '22 at 16:01
  • 1
    I extracted the necessary code to get a minimal, reproducible example. The result are around 1000 lines and there it works. Hmm. I'll have to search for differences.. . – manon Sep 30 '22 at 12:29
  • With replacing IgnoreAllUnmapped with .ForAllOtherMembers(opt => opt.Ignore()) it worked. Is that logic? – manon Oct 05 '22 at 11:44
  • What you're doing doesn't look good. Like at all :) `ForAllOtherMembers` no longer exists for a reason. – Lucian Bargaoanu Oct 05 '22 at 13:01

0 Answers0