我正在使用异步方法使用下面的代码返回通用结果,但出现以下错误:
错误:“传递到字典中的模型项的类型为'System.Collections.Generic.List
1[System.Collections.Generic.List
1 [IMS.ViewModel.BranchVM]]',但是此字典需要类型为'的模型项System.Collections.Generic.List`1 [IMS.ViewModel.BranchVM]'“
public async Task<'ActionResult'> ViewBranches()
{
UserManager<ApplicationUser> userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
var currentUser = userManager.FindById(User.Identity.GetUserId());
var result = await db.ExecuteQueryAsync<object, List<BranchVM>>("GetBranches", new { CompanyId= currentUser.CompanyId});
return View(result);
}
在“剃刀”视图中:
@model List<IMS.ViewModel.BranchVM>
@{
ViewBag.Title = "Branches";
Layout = "~/Views/Shared/_LayoutSMS.cshtml";