How to use PagedList in a web application based on ASP MVC in combination with ViewModels.
I want to make a PagedList of Viewmodels, so first I have to map the Entities to Viewmodels.
When I fetch a large list, it it very slow because first the mapping is executed before the PagedList is made (so the whole List of Entities is fetched).
What is the best way to solve this issue?
IEnumerable<InvoiceData> invoiceData = dataService.GetInvoiceData(locationId);
Mapper.CreateMap<InvoiceData, ViewModelInvoiceData>();
IEnumerable<ViewModelInvoiceData> vmInvoiceData = Mapper.Map<IEnumerable<InvoiceData>, IEnumerable<ViewModelInvoiceData>>(invoiceData);
IPagedList<InvoiceDataViewModel> pagedListVMInvoiceData = vmInvoiceData.ToPagedList(page, pageSize);
(I also use a mapping framework, but it's of course the same problem with a custom mapper class)
Why you didn't page your data on server? And after that create manual pager like in example 2 from troygoode / PagedList ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With