Open ChristoGC opened 1 year ago
Hello, named tuple, not named before compile. then always == Tuple<type1, type2> with tipe1 item1, type2 item2. You mapping for name, but name Not achievable, including for reflection, and after compile. Name use only when development type helpers
Hello @ChristoGC If You get This Result?
[TestMethod]
public void MappedNamedTuple()
{
TypeAdapterConfig<GroupDM604, (AuthorizationGroup604 authorizationGroup, GroupDetails604 groupDetails)>
.NewConfig()
.Map(dest => dest.authorizationGroup, src => src)
.Map(dest => dest.groupDetails, src => src);
GroupDM604 groupDM = new() { Name = "Hello world", Description = "Jon Bon Jovi" };
// Create a new instance of (AuthorizationGroup, GroupDetails): This works
var tuple = groupDM.Adapt<(AuthorizationGroup604 authorizationGroup, GroupDetails604 groupDetails)>();
// Now lets update poco
groupDM.GroupId = 99;
groupDM.Description = "Led Zep";
//Now lets update tuple: Doesn't work
groupDM.Adapt(tuple);
tuple.groupDetails.GroupId.ShouldBe(99); // true
tuple.authorizationGroup.Description.ShouldBe("Led Zep"); // true
}
I thought I would flag an issue I observed.
When following the example in https://github.com/MapsterMapper/Mapster/wiki/Custom-mapping Example 2: Mapping 2 objects to poco there seems to be an issue when reversing the mapping. Creating a new tuple from from a poco is fine, but updates do not work.
Example code
The expression scripts produced suggest that CreateMapToTargetExpression on poco to tuple is incorrect as it is exactly the same as CreateMapExpression
Thanks in advance,
Chris