Replies: 1 comment 4 replies
-
I think this is better suited for StackOverflow. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have two objects:
Foo1
)Foo1
sent to a remote REST API and that is mostly similar but not entirely (Foo2
).Using AutoMapper, I want to "merge"
Foo1
intoFoo2
. One thing I think that makes this tricky is thatFoo2
expects a list ofNestedObject2
, whereasFoo1
only has a singleNestedObject1
instead of a list. Due to the way the API works,NestedObject2
will never have more than one item in it. I put more than one in my unit test only to show that"one"
gets replaced (updated) and"two"
doesn't get clobbered (to verify merge behavior).Below is a unit test with example objects that represent what I'm trying to do. The problem is that
AfterMap
gives me a destination dictionary (ExtraObjects
) that is empty. I'm not sure why. Honestly, the whole way I've set up the mapping profile just "feels" wrong to me. I don't feel confident that I'm doing this right.How should I get this working?
The objects:
The mapping profile:
And the unit test:
The result of the test is:
Beta Was this translation helpful? Give feedback.
All reactions