I am able to map group of sametype of collections to a single collection using the below code.
AutoMapper.Mapper.CreateMap<Source, Destination>().ForMember(
dest => dest.Drivers,
opt => opt.MapFrom(src => src.BikeDrivers.Concat(src.CarDrivers).Concat(src.TruckDrivers)));
With the above solution I am able to map all the three type of drivers into one collection. My destination object (Driver) has a property called DriverType which helps in identifying the type of driver. (BikeDriver/CarDriver/TruckDriver)
In the above code, how i can set the DriverType property based on the collection I am adding.
for eg: i have to hard code
DriverType = CarDriver for CarDrivers collection items DriverType = BikeDriverfor BikeDrivers collection item.
Thanks in advance
To set the DriverType property you have to have this knowledge in your source object. I can't see your big picture, but this maybe used as a sample