RMG060 — Multiple user-mappings discovered without specifying an explicit default
Multiple user-mappings for the same type pair are discovered without specifying an explicit default. Mapperly needs to now which mapping it should use.
To specify a default apply [UserMapping(Default = true)]
.
See also user-implemented mappings.
Example
Two mappings from Car
to CarDto
are defined.
When Mapperly needs to map from Car
to CarDto
in CarsToCarDtos
it needs to know whether to use CarToCarDto
or CarToCarDtoIgnoreId
.
Apply [UserMapping(Default = true)]
to the mapping which Mapperly should use
in such cases.
- Invalid
- Fixed
[Mapper]
public partial class CarMapper
{
public paratial List<CarDto> CarsToCarDtos(List<Car> cars);
public partial CarDto CarToCarDto(Car car);
[MapperIgnoreSource(nameof(Car.Id))]
public partial CarDto CarToCarDtoIgnoreId(Car car);
}
[Mapper]
public partial class CarMapper
{
public paratial List<CarDto> CarsToCarDtos(List<Car> cars);
[UserMapping(Default = true)]
public partial CarDto CarToCarDto(Car car);
[MapperIgnoreSource(nameof(Car.Id))]
public partial CarDto CarToCarDtoIgnoreId(Car car);
}