c# - Automapper map custom collection -


hi im having difficulties mapping custom pagedlist collection have created.

i have pagedlist interface this:

public interface ipagedlist<t> : ilist<t> 

and implementation:

public class pagedlist<t> : list<t>, ipagedlist<t> 

mapping config:

mapper.createmap<user, destinationviewmodel>()   .formember(f => f.score, m => m.mapfrom(s => s.anotherproperty)); 

i try map collection in controller action this:

var users = userservice.getpagedusers(page, size, sort, direction); var model = mapper.map<ipagedlist<user>, ipagedlist<destinationviewmodel>>(users); 

firstly, possible this? have had scout around on stack , havent found definitive answer. have had no luck far have received invalidcastoperations cannot map generic collection of user pagedlist of destinationviewmodel, thrown automapper. using different list type ilist when mapping model works, need use ipagedlist interface paging stuff has. appreciated, been pulling hair out long on this.

ended finding answer after more research, no, automapper doesnt support scenario out out of box. 2 options here are: custom iobjectmapper, using existing array/enumerablemappers guide, or write custom typeconverter.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -