Map property using specific method #162
Replies: 5 comments 4 replies
-
Currently we prioritize other features higher than this. We may reconsider this at a later point. |
Beta Was this translation helpful? Give feedback.
-
Yes - this would be very useful for us, as it's currently blocking us from using Mapperly. |
Beta Was this translation helpful? Give feedback.
-
This would be useful for me too. I want to convert a bool in the source to an int in the target, I know I can do it with a general type converter, but I only want it for a specific property, so seems a bit overkill. I can also do it in before/after map pattern, but also need to add an ignore for the property.. so it's a bit clunky. |
Beta Was this translation helpful? Give feedback.
-
I came looking for this as well. A lot of our properties are Just for reference, some of our 'special' cases are based around 2 properties being consolidated into a single one. Example below is how we resolved the issue in a proof of concept using mapster. I am not recommending following the mapster pattern to handle these scenarios, just providing this is a reference. public class Source
{
public required double Speed { get; init; }
public required SpeedUnit SpeedUnit { get; init; } // speed unit is an enum
}
public class Destination
{
public required double SpeedMph { get; init; }
} with mapster: TypeAdapterConfig<Source, Destination>
.ForType()
.Map(dest => dest.SpeedMph, src => SpeedCalculator.Convert(src.Speed, src.SpeedUnit, SpeedUnit.MPH)); |
Beta Was this translation helpful? Give feedback.
-
Handled in #783 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
i tried mapperly to replace automapper.
I'm missing a functionality that would be able to descriptively specify property mapping using a method.
eg.
A similar functionality can be using the "Before / after map" scenario, but that would violate the DRY principle.
Beta Was this translation helpful? Give feedback.
All reactions