I am trying to map source and destination instances using automapper,
I have a sample code which i have created . Line number 82 i am trying to change anduse automapper. Is it possible to use automapper there.
I am trying to map source and destination instances using automapper,
I have a sample code which i have created . Line number 82 i am trying to change anduse automapper. Is it possible to use automapper there.
Yes, you can map a list, but after taking a look at your code I don't think you need a list or array for the destinationArray field. If you need to use it as an array, all you have to do is adding.First() after destinationArray:
public static IMapper CreateGroboBookingMapper()
{
var config = new MapperConfiguration(cfg =>
{
cfg.AllowNullDestinationValues = true;
cfg.CreateMap<Booking, DestinationBooking>()
.ForMember(dest => dest.processTypeField, opt => opt.MapFrom(src => src.processTypeField))
.ForMember(dest => dest.travelDate, opt => opt.MapFrom(src => src.Trip.Voyages.FirstOrDefault().DepartureDate))
.ForMember(dest => dest.destinationArrayField, opt => opt.MapFrom(a => new destinationArray()
{
// Here you can add destinationArray models parameters
arrivalStationIdField= a.Trip.Voyages.Select(x => x.arrivalStationId).FirstOrDefault().ToString(),
extraField = *************
}));
});
return config.CreateMapper();
}
And here is the result from debugging, as I've tried one value:
