Automapper creating new instance rather than map properties

后端 未结 3 581
不思量自难忘°
不思量自难忘° 2020-12-15 21:05

This is a long one.

So, I have a model and a viewmodel that I\'m updating from an AJAX request. Web API controller receives the viewmodel, which I then update the ex

3条回答
  •  长情又很酷
    2020-12-15 21:59

    In the meantime there exists an AutoMapper Extension for that particular problem:

    cfg.AddCollectionMappers();
    cfg.CreateMap().EqualityComparison((s, d) => s.ID == d.ID);
    

    With AutoMapper.EF6/EFCore you can also auto generate all equality comparisons. Plaese see AutoMapper.Collection AutoMapper.EF6 or AutoMapper.Collection.EFCore

提交回复
热议问题