How can I make AutoMapper to map missing unmapped properties to a dictionary inside the destination object? (Like ExtensionData during serialization)
Example:
class Source
{
public int A {get;set;}
public int B {get;set;}
public int C {get;set;}
}
class Destination
{
public int A {get;set;}
public Dictionary<string, object> D {get;set;}
}
Source s = new Source { A = 1, B = 2, C = 3 };
Destination d = ... // Mapping code
Now I want the following result:
d.A ==> 1
d.D ==> {{ "B", 2 }, { "C", 3 }}
* EDIT *
In the end I am looking for a solution w/o reflection. Meaning: During setup/configuration/initialization reflection is allowed, but during the mapping itself, I do not want any delays caused by reflection.
* EDIT *
I am looking for a generic solution, just like the serializers.
There are a lot of possible solutions for your problem. I've create a custom value resolver for your property and it works perfectly:
How to use it?