I am trying to work out how to populate Foo from FooConfig:
class Bar
{
int A;
int B;
}
class Foo
{
Bar BarValues;
Bar BarErrorValues;
}
class FooConfig
{
int A;
int B;
int AError;
int BError;
}
FooConfig is essentially a flattened version of Foo.
I can populate the BarValues easily with AutoMapper (by having a map defined for FooConfig to Bar), but I am having trouble getting the BarErrorValues populated – everything I try it ends up with the A and B values in it instead of the AError and BError values.
I suspect I need to use a “transformer” or RecognizePostfixes (although this does not seem to work as I tried it).
I think I have found the problem. It appears that if AutoMapper finds an exact match then the name transformer is never used. Bugger 🙁 Here is the AutoMapper source code that shows it: