AutoMapper materializes default object when should be null?

Skip to first unread message

Brian Richardson

Jun 12, 2021, 3:52:45 PM6/12/21
to AutoMapper-users
I'm sorry if the subject is a bit unclear, but I'm running into a situation where AutoMapper seems to create an empty object of the destination type instead of simply setting null when the source property is null. The code in question is in

I refer to AddressAndLocationTests, TestRemove() in Bookstore.Services.People.Tests. I can verify that the database is correctly reflecting a deleted address, and if I follow along in the debugger, I can see that the related property is also null. But for some reason, when mapping it to the domain object, an empty Address object materializes! Can anyone suggest a reason that this empty object is popping into existence instead of simply being null?

Reply all
Reply to author
0 new messages