I looked around and could not find the answer to my question. What I want to do is a conditional map of the target object (not a field / property, object). In other words, something like this:
public class Source { public int Id {get; set;} public string Flag {get; set;} } public class Destination { public int Id {get; set;} } var sources = new List<Source> { new Source{Flag = "V", Id = 1}, new Source{Flag = "B", Id = 2} }; var destinations = Mapper.Map<List<Source>, List<Destination>>(sources); destinations.Count.ShouldEqual(1); destinations[0].Id.ShouldEqual(2);
Does anyone know how to set up type matching? I am looking for something like:
Mapper.CreateMap<Source, Destination>() .SkipIf(src => src.Flag != "B");
I just don't see anything in the configuration settings that seem to support this. Any help is appreciated! Thanks in advance.
source share