Mapster ignore mapping in a list

Viewed 300

If I have a parent object with a list of child objects, and these child objects have a boolean telling should they be included in the mapping, how can I do this filtering in Mapster?

Code example:

class Parent
{
   public List<Child> Children {get;set;}
}
class Child
{
   public double SomeValue {get;set;}
   public bool ShouldMap {get;set;}
}

And dto objects:

class ParentDto
{
   public List<ChildDto> Children {get;set;}
}
class ChildDto
{
   public double SomeValue {get;set;}
}

There seems to be an IgnoreIf function, but I couldn't get that to work in this case.

0 Answers
Related