我想使用AutoMapper将ViewModel映射到域模型类。我也在使用PagedList NuGet Package。我这样用它:
[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));
}
不幸的是我收到了错误:
缺少类型映射配置或不支持的映射。映射类型:ErrorsLog - > ErrorsLogViewModel DigitalHubOnlineStore.Models.ErrorsLog - > DigitalHubOnlineStore.ViewModels.ErrorsLogViewModel目标路径:ErrorsLogViewModel源值:PagedList.PagedList`1 [DigitalHubOnlineStore.Models.ErrorsLog]
我该如何解决?