Reputation: 451
I have following code where I want to Map dto into an existing object. I'd expected that the Update method in AddressMapper got called, but the Create gets called.
I can't really find anything useful in the documentation. How should I fix this the correct way?
[Mapper]
[UseStaticMapper(typeof(AddressMapper))]
public static partial class CompanyUpdateMapper
{
private static partial void Map(CompanyUpdateDTO request, Company company);
public static Company Map(CompanyUpdateDTO request, IRepository repository)
{
Company company = repository.GetById<Company>(request.Id, ["Address"]);
Map(request, company);
return company;
}
}
[Mapper]
public static partial class AddressMapper
{
private static partial Address MapInternal(AddressDTO address);
public static Address Create(AddressDTO address)
=> MapInternal(address) ?? new Address();
[MapperIgnoreTarget(nameof(Address.Id))]
public static partial void Map(AddressDTO addressDTO, Address address);
}
Upvotes: 0
Views: 96