我正在尝试根据条件从不同的源属性映射viewmodel属性。我希望根据类型从ContactIndividual或Individual映射详细信息。我收到错误 - Individual和ContactIndividual之间没有隐式转换
Mapper.CreateMap<Individual, MyParentVM>()
.ForMember(x => x.Number, o => o.MapFrom(s => s.Code))
.ForMember(x => x.Details, o => o.MapFrom(s => (s.Type == AType.Individual) ? s as Individual: s.Contact as ContactIndividual));
Mapper.CreateMap<Individual, MyDetailsVM>();
Mapper.CreateMap<ContactIndividual, MyDetailsVM>();