UseDestinationValue only when destination property is not null

后端 未结 3 1644
不知归路
不知归路 2021-01-18 08:59

How to configure AutoMapper mapping when I want to use behaviour from UseDestinationValue method, but only when destination property is NOT null.

3条回答
  •  日久生厌
    2021-01-18 09:54

    I had this same problem dealing with NHibernate entities and I found quite simple solution to it.

    You should initialize the Details property in the ItemViewModel constructor. This way the destination value is not null ever. Of course this does not work in more complex cases (like abstract classes).

提交回复
热议问题