I\'d like to map a paged list of business objects to a paged list of view model objects using something like this:
var listViewModel = _mappingEngine.Map
AutoMapper does not support this out of the box, as it doesn't know about any implementation of IPagedList<>
. You do however have a couple of options:
Write a custom IObjectMapper
, using the existing Array/EnumerableMappers as a guide. This is the way I would go personally.
Write a custom TypeConverter, using:
Mapper
.CreateMap, IPagedList>()
.ConvertUsing();
and inside use Mapper.Map
to map each element of the list.