v4.2からAutoMapper 5.1にアップグレードしようとしていて、コレクションが実行時にマッピングされていないことがわかっています - ソースオブジェクトはコレクションにアイテムを持っています。同じマッピングの設定で、予想通り4.2の下でネストされたコレクションがAutoMapper 5.1で機能していない
、すべてが
(CreateMap()ctorの中MemberList.Noneのために保存)を正確に働いていた私のようなので、
public class GeographicEntity
{
...
}
public class County : GeographicEntity
{
...
}
public class State : GeographicEntity
{
public List<County> Counties { get; } = new List<County>();
}
とのviewmodelsのようなのDTOを持っていますそう
のようなので、public class GeographicEntityViewModel
{
...
}
public class CountyViewModel : GeographicEntityViewModel
{
...
}
public class StateViewModel : GeographicEntityViewModel
{
public List<CountyViewModel> Counties { get; } = new List<CountyViewModel>();
}
とマッピングの確認
Mapper.Map <>呼び出した後、StateViewModelの郡収集は、ソースオブジェクトがその.Countiesコレクション内のアイテムがあっても(0アイテムとリスト)が空である:
var st = new State()
... (initialize the state, including the .Counties list)
var stateViewModel = Mapper.Map<StateViewModel>(st);
任意の手がかりありがとう!