Skip to content

Support for appending to an existing target object #151

Description

@DedAnton

Discussed in #150

Originally posted by TallBaldGeek August 15, 2023
I was testing out NextGenMapper to see if it could replace some reflection-based mapping that we're currently doing in our application. It looks like a promising fit, but we have many use cases where we need to map several source objects to a single target object.

For example, if the target comprised of data from multiple sources as follows:

record SourcePhone(string PhoneNumber, string PhoneType);
record SourceName(string FirstName, string LastName);
record CustomerDto(string PhoneNumber, string PhoneType, string FirstName, string LastName);

It would be helpful to be able to build a complete CustomerDto by combining data from several sources:

var phone = new SourcePhone("5556667777", "Mobile");
var name = new SourceName("First", "Last");
var customer = phone.Map<CustomerDto>();
customer.MapAppend(name);

//or possibly in a fluent syntax?
var customer = phone.Map<CustomerDto>().Append(name);

This feature would be similar to Mapperly's support for using an existing target object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions