-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
Labels
Description
Issue #180 shows how to solve the need for multiple sources using tuples, and that it is implemented in Mapster 5.0.
However, using multiple sources as stated in the docs introduces a heavy constraint, which is to map every member manually.
In the following code, dto.CommonValue is null if not explicitly mapped in the config.
record PocoA(string SpecificValue);
record PocoB(int CommonValue);
record Dto(int CommonValue, int SumValue);
//...
TypeAdapterConfig.GlobalSettings.NewConfig<(PocoA, PocoB), Dto>()
.Map(dto => dto.SumValue, pocoTuple => pocoTuple.Item1.SpecificValue + pocoTuple.Item2.CommonValue);
// ...
var dto = mapper.Map<(PocoA, PocoB), Dto>(pocoA, pocoB); // dto.CommonValue is nullIs there a solution to this?
It breaks the workflow in some large objects. If a single parameter needs an additional source, every single member needs to be mapped manually.