Mapping output affected by the order of base class maps in a profile #4094
Unanswered
danielgreen
asked this question in
Q&A
Replies: 1 comment 12 replies
-
Just by looking at your maps, I cannot say what the result should be :) |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The order that maps are set up in a profile seems to affect the output of mapping operations.
Full repro in this minimal .NET 6 console app:
https://github.com/danielgreen/AutoMapperScratchApp
Source/destination types
Mapping configuration
Version: 12.0.0
Expected behavior
Expected the behaviour of both profiles would be the same.
Thought that FooText would be mapped in both cases, because the <Bar, IFoo> map (which maps the property) is more derived than the <object, IFoo> map (which ignores the property).
That was based on my reading of these docs:
https://docs.automapper.org/en/stable/Mapping-inheritance.html
Actual behavior
The FooText property value is not mapped when using ProfileA, but the value is mapped when using ProfileB.
The only difference between ProfileA and ProfileB is the <Bar, IFoo> and <object, IFoo> maps appear in a different order.
Is it expected behaviour that the order that maps appear in a profile would determine the output?
If it is expected, is that documented (sorry if I missed it), or how should developers work with that?
If it is not expected, which profile is producing the correct output here?
Steps to reproduce
Beta Was this translation helpful? Give feedback.
All reactions