Ignoring the value 0 in non-nullable numeric variables in Mapster
I want to create a very simple mapping. My class is as follows:
public class C
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
Here's a sample value and test:
C cat = new C() { Age = 8 };
C cat2 = new C() { Id = 2, Name = "Jana", Age = 20 };
TypeAdapterConfig.GlobalSettings.Default.IgnoreNullValues(true);
var output = cat.Adapt(cat2);
It ignores null values, but it doesn't ignore numeric values that are 0, which breaks the mapping. Does anyone have a solution for this?
You can ignore members conditionally https://github.com/MapsterMapper/Mapster/wiki/Ignoring-members#ignore-conditionally