5

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

but It uses the Initialize method so all the mappings behavior would change along the app : O

And I just need do it for a specific mapping.

1 Answer 1

9

Found a solution:

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

Thanks guys : )

Take care of your destination field types (remember you need nullable types. e.g. 'Byte?' )

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.