title: Asp.net Core how to use ReflectionIT with ViewModel?
body: <p>I want to use paging with a ViewModel in Asp.net Core 2.2.</p>
  
  <p>You can see my code below</p>
  
  <pre><code> public class KiemDinhLoginViewModel
  {
      public string MaTruong { get; set; }
      public string MatKhau { get; set; }
      public string TenDonVi { get; set; }
      public string Quan { get; set; }
      public string DiaChi { get; set; }
      public int MaCapHe { get; set; }
      public bool? Active { get; set; }
      public string Quyen { get; set; }
  
      public string TenCapHe { get; set; }
  }
  </code></pre>
  
  <p>And in my Controller</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using AutoMapper;
  using KhaoThiKiemDinh.Models;
  using KhaoThiKiemDinh.ViewModels;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.EntityFrameworkCore;
  using PagedList.Core;
  using ReflectionIT.Mvc.Paging;
  
  namespace KhaoThiKiemDinh.Areas.Admin.Controllers
  {
      [Area("admin")]
      public class DanhSachDangNhapController : Controller
      {
          private readonly ngoaingusgd_com_Context _context;
          private readonly IMapper _mapper;
          public DanhSachDangNhapController(ngoaingusgd_com_Context context, IMapper mapper)
          {
              _context = context;
              _mapper = mapper;
          }
          public async Task&lt;IActionResult&gt; Index(int page = 1)
          {
              var KiemDinhLogin = _context.KiemDinhLogin.AsQueryable();
              var result = KiemDinhLogin.Include(p =&gt; p.MaCapHeNavigation).OrderBy(p =&gt; p.Quan);
              var model = await PagingList.CreateAsync(result, 5, page);
              return View(_mapper.Map&lt;List&lt;KiemDinhLoginViewModel&gt;&gt;(model));
          }
      }
  }
  </code></pre>
  
  <p>And below is MappingProfile</p>
  
  <pre><code>namespace KhaoThiKiemDinh.Models
  {
      public class MappingProfile : Profile
      {
          public MappingProfile()
          {
              CreateMap&lt;KiemDinhLogin, KiemDinhLoginViewModel&gt;().
                  ForMember(dest =&gt; dest.TenCapHe, opt =&gt; opt.MapFrom(src =&gt; src.MaCapHeNavigation.TenCapHe));
          }
      }
  }
  </code></pre>
  
  <p>At the end Index.cshtml</p>
  
  <pre><code>@model ReflectionIT.Mvc.Paging.PagingList&lt;KhaoThiKiemDinh.ViewModels.KiemDinhLoginViewModel&gt;
  @using ReflectionIT.Mvc.Paging
  @addTagHelper *, ReflectionIT.Mvc.Paging
  
      @await this.Component.InvokeAsync("Pager", new { paginglist = this.Model })
  
     &lt;table&gt;...&lt;/table&gt;
  
  
      &lt;vc:pager paging-list="@Model"&gt;&lt;/vc:pager&gt;
  </code></pre>
  
  <p>But i get below error</p>
  
  <p>An unhandled exception occurred while processing the request.
  InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Collections.Generic.List<code>1[KhaoThiKiemDinh.ViewModels.KiemDinhLoginViewModel]', but this ViewDataDictionary instance requires a model item of type 'ReflectionIT.Mvc.Paging.PagingList</code>1[KhaoThiKiemDinh.ViewModels.KiemDinhLoginViewModel]'.</p>
  
  <p>Please help me. Thanks.</p>