c# - How to use AutoMapper with PagedList? -


i'd use automapper in order map viewmodel domain model class. i'm using pagedlist nuget package. i'm using way:

[authorize] [automap(typeof(errorslog), typeof(errorslogviewmodel))] public actionresult errors(string searchstring, string currentfilter, int? page) {     if (searchstring != null)     {         page = 1;     }     else     {         searchstring = currentfilter;     }      var el = _er.geterrorslog();     viewbag.currentfilter = searchstring;      if (!string.isnullorempty(searchstring))     {         el = el.where(s => s.errorsource.contains(searchstring));     }      const int pagesize = 3;     int pagenumber = (page ?? 1);     return view("errors", el.topagedlist(pagenumber, pagesize)); } 

unfortunately got error:

missing type map configuration or unsupported mapping. mapping types: errorslog -> errorslogviewmodel digitalhubonlinestore.models.errorslog -> digitalhubonlinestore.viewmodels.errorslogviewmodel destination path: errorslogviewmodel source value: pagedlist.pagedlist`1[digitalhubonlinestore.models.errorslog]

how can fix that?

did have register mappings? error message, seems didn't call createmap method anywhere yet.
take @ this.

edit

as mentioned here, can create static class mappings...

public static class automapperconfig {    public static void configure()    {           mapper.createmap<errorslog, errorslogviewmodel>();    } } 

and call in global.asax:

automapperconfig.configure(); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -