You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a nested source object like:
{
homeAddress: {
address1: '100 Main St',
address2: 'Apt# 1',
city: 'Los Angeles',
state: 'CA',
zip: '90000'
},
businessAddress: {
address1: '200 Main St',
city: 'Los Angeles',
state: 'CA',
zip: '90000'
}
}
However, homeAddress sometimes could be null because businessAddress is filled in. When I try to map the source object to a DTO, I'll get an exception because automapper cannot read homeAddress.address1. Is there a way to initialize automapper to map anything it couldn't resolve to null? in this case (homeAddress = null) the destination object should simply be:
{
homeAddress: null,
businessAddress: {
address1: '200 Main St',
address2: null,
city: 'Los Angeles',
state: 'CA',
zip: '90000'
}
}
thanks
The text was updated successfully, but these errors were encountered:
I have a similar situation, though for me, using your data in my example homeAddress would not be present at all! This is true of all other attributes in the inbound message - it's a SCIM 2.0 PUT request. Hoping there's a neat way to use AutoMapper to cater for this.
So what I'm really after is map and transform only if the source attribute exits.
Hi both, thanks for commenting! I have been busy lately starting my own IT consultancy firm ;). I will try to react in detail somewhere this week! Thanks for your patience! Cheers, Bert
Hi both, I have just pushed a fix (1.7.2) to the repository. I will push it to NPM as soon as possible. Please let me know if this fix does work for you. FYI, if you specify nested mappings, you currently have to specify all of them, since the current solution does either use auto mapping or property mapping. I did already write a unit test to reproduce this issue, the fix is a bit harder than I would like to implement at this very moment ;)...
We have a nested source object like:
{
homeAddress: {
address1: '100 Main St',
address2: 'Apt# 1',
city: 'Los Angeles',
state: 'CA',
zip: '90000'
},
businessAddress: {
address1: '200 Main St',
city: 'Los Angeles',
state: 'CA',
zip: '90000'
}
}
However, homeAddress sometimes could be null because businessAddress is filled in. When I try to map the source object to a DTO, I'll get an exception because automapper cannot read homeAddress.address1. Is there a way to initialize automapper to map anything it couldn't resolve to null? in this case (homeAddress = null) the destination object should simply be:
{
homeAddress: null,
businessAddress: {
address1: '200 Main St',
address2: null,
city: 'Los Angeles',
state: 'CA',
zip: '90000'
}
}
thanks
The text was updated successfully, but these errors were encountered: