Open nikitabraganov opened 7 months ago
I migrated from AutoMapper, and there I had the "AllowNullDestinationValues" property on the MapperConfiguration.
@andrerav
A little too late to the party but I just hit the same problem. This is how I fixed it
config.NewConfig<ProductCategory, SaveProductCategoryDto>()
.MaxDepth(1);
config.NewConfig<SaveProductCategoryDto, ProductCategory>()
.IgnoreMember((member, side) => side == MemberSide.Destination
&& member.Name.Equals(nameof(ProductCategory.Company)))
.IgnoreNullValues(true)
.MaxDepth(1);
where ProductCategory
is a data entity, retrieved from DB that has a navigational prop to Company, not required and not needed when creating a new ProductCategory
.
Best, Simo
I have the following classes:
ScheduleWrapper
Schedule
When I try to adapt ScheduleWrapper to Schedule, on Schedule an empty Company object will be created instead of null.
Other configurations are:
I noticed this behavior also in other places where the explicit mapping is not defined.
Is there a setting to not create empty objects on destination when it not exists on source?