If else in AutoMapper ForMember

Viewed 5662

I am trying to map two different objects

CreateMap<A, B>()
  .ForMember(x => x.Quantity, y => y.MapFrom(z =>z.QuantityList.First().TotalQuantity))

I would like to assign x.Quantity = 1 if z =>z.QuantityList.First().TotalQuantity == 0 othwerwise the above mapping.

How is this done in ForMember()?

3 Answers
Related