riok / mapperly

A .NET source generator for generating object mappings. No runtime reflection.
https://mapperly.riok.app
Apache License 2.0
2.87k stars 146 forks source link

Map to nested existing target instances #1311

Open latonz opened 5 months ago

latonz commented 5 months ago

Nested objects in existing target mappings should preserve the existing instance if possible. Currently always a new instance of the nested object is created.

Rel. #1310 More details in #1484

ste4net commented 1 month ago

Any update on this? It is really important for me. I am trying to implement mapping for objects like

public class Company
{
 ...
  public List<Address> Addresses{get;set;}
}

having the possibility to update list of entities when entity exist in source and target list, remove entities from target if not present in source and ad entities if added in source. Without this i am not able to find a way to map enumerable properties because i have this approach for all List properties. I guess the only way should be using MapperIgnore for each enumerable properties and wrap mapper call in custom method to manually update the enumerable child properties but it's a lot of work . I was trying to move from Automapper but this part block mi migration.

Thankyou very much

p.s. Maybe this issue is related to #1484