The destination class has a list of bools. The DTO that gets mapped to the destination class has 1 enum property. depending on what the enum is some of the bools in the destination class should be set. how to achieve it in automapper?
.ForMember() won't work because i would have to do enum logic check for each of the bool property.
I want to do a mapping this.CreateMap<DestinationDTO, Destination>() where depending on what the payout is Property1 or Property2 or Property3 gets set.
See below:
public class Destination
{
public bool? Property1{get; set;}
public bool? Property2{get; set;}
public bool? Property3{get;set;}
}
public class DestinationDTO
{
public Enum Payout{get; set;}
}
public Enum Payout
{
Proration = 1,
Recurrent = 2,
Lumpsum = 3
}
If the DestinationDTO.Payout == Payout.Proration, I want to set Destination entity class's Property1 to be true, similarly depending on what payout it is, I might want to set another Property in the entity class. Can I do this in automapper when mapping the DestinationDTO to Destination entity class?