Skip to content

Meaning of mapping to an existing object? #430

@zhenlei520

Description

@zhenlei520

Meaning of mapping to an existing object?

I used map to existing object, but I found that it doesn't preserve the value of the existing object during the mapping process, it initializes the value of the existing object, and when the existing object is a collection, the value of the existing object is the same as The response data is not the same, but I think their result should be the same

[TestMethod]
public void TestMapToExistingObject()
{
    List<UserDto> sources = new List<UserDto>()
    {
        new()
        {
            Name = "Jim",
            Age = 18
        }
    };

    List<UserDto> destination = new List<UserDto>();
    sources.Adapt(destination);
    Assert.IsTrue(destination.Count == sources.Count);//But it is not established at present, I think he is a bug
}

public class UserDto
{
    public string Name { get; set; }

    public int Age { get; set; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions