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
{{ message }}
Repository navigation
Can mapperly do generic type conversions of properties or wrap all generated property maps with a custom static mapper?
#2149
UpdateContributionInput has a bunch of fields with the same names as ContributionEntity but the types on the input side are Optional<> generics of the types on the entity side. If the types were the same we would have a mapperly version:
[Mapper]publicclassContributionMapper{// I need to get all relevant properties to be mapped via this methodpublicstaticTMapOptionalMember<T>(Optional<T>source,Ttarget)=>source.HasValue?source.Value:target;[MapperIgnoreTarget(nameof(CashTransactionEntity.Id))]publicstaticpartialvoidMapToCashTransactionEntityInternal(UpdateContributionInputsource,CashTransactionEntitytarget);}
but because (almost) all the properties on source are Optional (for example Optional<string?> Comment on source vs string? Comment on target), the properties are not being mapped properly since an implicit cast exists from Optional<string?> to string? (removed some namespaces and unnecessary code):
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm looking to convert from automapper but I can't figure out what to look for for the equivilant of this:
UpdateContributionInputhas a bunch of fields with the same names asContributionEntitybut the types on the input side areOptional<>generics of the types on the entity side. If the types were the same we would have a mapperly version:but because (almost) all the properties on source are
Optional(for exampleOptional<string?> Commenton source vsstring? Commenton target), the properties are not being mapped properly since an implicit cast exists fromOptional<string?>tostring?(removed some namespaces and unnecessary code):For reference the Optional type:
Note:
[UserMapping]doesn't work because I need to consider the existing target value, I'm looking for something roughly like this:or
All reactions