Skip to content

mapping two source props to one target prop #727

Closed Answered by TimothyMakkison
senal asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, thanks for using Mapperly. It looks like before/after mapping could work.

[Mapper]
public static partial class Mapper
{
    // tell mapperly it doesn't need to resolve Make, we will do it ourselves
    [MapperIgnoreTarget(nameof(CarDto.Make))]
    private static partial CarDto InternalMapCarToDto(Car car);

    public static CarDto MapCarToDto(Car car)
    {
        var target = InternalMapCarToDto(car);
        target.Make = $"Merged {car.Brand} + {car.Model}";
        return target;
    }
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@senal
Comment options

Answer selected by latonz
Comment options

You must be logged in to vote
1 reply
@TimothyMakkison
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants