Can Automapper map a paged list?

前端 未结 6 1902
我寻月下人不归
我寻月下人不归 2021-02-01 19:38

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

        
6条回答
  •  一生所求
    2021-02-01 19:58

    AutoMapper automatically handles conversions between several types of lists and arrays: http://automapper.codeplex.com/wikipage?title=Lists%20and%20Arrays

    It doesn't appear to automatically convert custom types of lists inherited from IList, but a work around could be:

        var pagedListOfRequestForQuote = new PagedList(
            AutoMapper.Mapper.Map, List>(((List)requestForQuotes),
            page ?? 1,
            pageSize
    

提交回复
热议问题