可以使用ToList()方法将IEnumerable类型的Model转换为List类型,示例代码如下:
// 原始代码 public IActionResult Index() { IEnumerable students = _context.Students; return View(students); }
// 转换为List类型的代码 public IActionResult Index() { List students = _context.Students.ToList(); return View(students); }
上一篇:ASP.NETCore6如何导出PDF?
下一篇:ASP.NETCore6如何使用DateOnly/TimeOnly查询参数?