You do not need to explicitly map collection types, only the item types. Just do:
Mapper.CreateMap<SentEmailAttachment, SentEmailAttachmentItem>();
var attachments = Mapper.Map<IEnumerable<SentEmailAttachment>, List<SentEmailAttachmentItem>>(someList);
That will work just fine.
EDIT: I found an easy way to use DynamicMap with collections.
IEnumerable<FakeItem> unmappedItems = Repository.GetItems();
IEnumerable<MappedItem> mappedItems = unmappedItems.Select(Mapper.DynamicMap<MappedItem>);
— Original message —
The way Jimmy says to use it works, but I try to use DynamicMap when I can to avoid having to do "CreateMap" for every mapping I need. I don't think DynamicMap works with collections very well, if at all. It does not throw an exception, but the result is an empty set.
From testing over the past couple of days, you cannot use DynamicMap for collections at this time (that I know of).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With