Skip to content

Merge multiple source into one destination #1978

@Chaosflo

Description

@Chaosflo

Is your feature request related to a problem? Please describe.
We started to transfer from AutoMapper to Mapperly.
Sometimes we use the merging feature, means we have two objects which we want to merge into one.

public class SourceA
{
	public string A { get; set; }

	public string B { get; set; }
}

public class SourceB
{
	public string C { get; set; }

	public string D { get; set; }
}

public class Destination
{
	public required string A { get; init; }

	public required string B { get; init; }

	public required string C { get; init; }

	public required string D { get; init; }
}

As you see I have SourceA and SourceB and I have Destination class.
Also you see that SourceA contains different properties than SourceB.
The required init is place there on purpose.

Currently I have not found any solutions to this.

Describe the solution you'd like
I would like to do something like this with additional parameters which is already existing

public static partial Destination ToDestination(this SourceA sourceA, [MapAdditionalSource]SourceB sourceB);

Describe alternatives you've considered
I am open to any api, if it solves the problem.
Changing the required to non required is not an option

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions