mapperly

Mapperly - Nested object displays error from parent object when it is already mapped


I'm trying to create a mapper with mapperly 3.5.0 and I get an error on the customer object that says a related object is missing a mapping even though it is there. Any ideas how to resolve this or explain what I am missing?

enter image description here

Thanks


Solution

  • It seems that you have strict mappings enabled, therefore unmapped members lead to error diagnostics instead of informational ones. The member ProvisionalHerdsDBO.Customer inside your CustomerDTO Convert(CustomerDBO) mapping is not mapped to any target. Without knowing your exact object tree I assume CustomerDBO has a (nested) member of type ProvisionalHerdsDBO. You have mapping definitions for a mapping from ProvisionalHerdsDTO to ProvisionalHerdsDBO which ignores this field on the target. But the mapping in question is the other way around, so what you probably need is:

    [MapperIgnoreSource(nameof(ProvisionalHerdsDBO.Customer))]
    public static partial ProvisionalHerdsDTO Convert(ProvisionalHerdsDBO provisionalHerd);
    

    This states that for a mapping from ProvisionalHerdsDBO to ProvisionalHerdsDTO the member ProvisionalHerdsDBO.Customer should be ignored. This mapping should then be used by Mapperly and the related RMG020 should not appear anymore. The same applies to ProvisionalHerdsExclusionDBO.ProvisionalHerds.