我試圖找出如何從FooConfig
填充Foo
:Automapper:忽略精確匹配和使用後綴匹配,而不是
class Bar
{
int A;
int B;
}
class Foo
{
Bar BarValues;
Bar BarErrorValues;
}
class FooConfig
{
int A;
int B;
int AError;
int BError;
}
FooConfig
本質上是Foo
扁平版本。
我可以(通過具有FooConfig
到Bar
定義地圖)填充容易與AutoMapper的BarValues
,但我遇到麻煩BarErrorValues
填充 - 一切,我嘗試在它結束了與A
和B
值,而不是AError
和BError
值。
我懷疑我需要使用「變壓器」或RecognizePostfixes
(雖然這似乎並不像我試過的那樣)。
嗨帕特里克我試圖避免每個成員寫ForMember(我實際上有50多個),如果我要這樣做,那麼我可能會寫一個手動X = Y函數 – Schneider 2010-11-03 02:34:48