Mapster icon indicating copy to clipboard operation
Mapster copied to clipboard

Having a IgnoreDefaultValues for Merging

Open tgranie opened this issue 2 years ago • 0 comments

Hello, Thanks for helping developers with such great packages ! I'm using Mapster specifically for merging objects. In order to avoir erasing destination members with source null values and default, it would be great to provide IgnoreDefaultValues as follow :

public static T Merge<T>(T src, T dst) where T : class
  {
      TypeAdapterConfig.GlobalSettings.Default.IgnoreNullValues(true);
      TypeAdapterConfig.GlobalSettings.Default.IgnoreDefaultValues(true);
      return src.Adapt(dst);
  }

Thanks for your help

tgranie avatar Mar 13 '23 22:03 tgranie