I would say this is cannot be done with AutoMapper as the time being. The instance caching is built in pretty deep and currently it can't be turned off easily. Altough your use case is very strange... having the same source object multiple times in a list but you still want different destination objects is quite unusual in my point of view.
But it can be worked around with a pretty bad hack, because it will turn off instance caching globally and relies on the implementation details of AutoMapper so use it carefully. And if you still want to try it out the below mentioned solution is not working with Automapper 2.2.0 because of a bug which is only fixed in the development branch so you need to build AutoMapper from source or wait for the next release.
But nevertheless here are the details
The instance caching is handled by the TypeMapObjectMapperRegistry.CacheMappingStrategy
[source] which like all the other ITypeMapObjectMapper
implementation is a private class.
However the TypeMapObjectMapperRegistry.AllMappers
field which should return all the ITypeMapObjectMapper
is a public Func
which can be overridden:
So add this code before the first usage of the Mapper class:
var baseMappers = TypeMapObjectMapperRegistry.AllMappers();
TypeMapObjectMapperRegistry.AllMappers = () =>
baseMappers.Where(m => m.GetType().Name != "CacheMappingStrategy").ToArray();
Mapper.CreateMap<Source, Destination>();