I have one very general object that I want to map to the destination type using AutomMapper, but I want to map it to different types depending on the value of the property in the source type. For example, suppose I have:
public class Source
{
public string Discriminator { get; }
public string ValueA { get; }
public string ValueB { get; }
}
public class Target
{
public string Value { get; set; }
}
And I want to map Source.ValueA to Target.Value if Source.Discriminator == "A" and Source.ValueB for Target.Value if Source.Discriminator == "B".
Is this possible with AutoMapper?
source
share