How to map null values ​​to AutoMapper for a specific mapping?

I found this AutoMapper solution - setting the final string to null actually makes it string.Empty

but it uses the Initialize method, so all display behavior will change with the application: O

And I just need to do this for a specific comparison.

+4
source share
1 answer

Found a solution:

Mapper.Initialize( Conf => { Conf.ForSourceType<MyGreatViewModel>().AllowNullDestinationValues = true; } ); 

Thanks guys:)

Take care of your destination field types (remember that you need types with a null value, such as "Byte?")

+7
source

Source: https://habr.com/ru/post/1300200/


All Articles