가 return View(await _context.Reviews.ToListAsync);
다음과 같은 오류주는 문제 갖는 '를 찾을 수 없습니다 네임 스페이스 이름'ASPNETCoreWebApplication ' "및"'방법 그룹 '기다리고 수 없습니다 ": 나는 믿고 리드 해요 Cannot await 'method group'
ASP.NET MVC -
을 return View(await _context.Reviews.ToListAsync);
문을 사용하려면 using ASPNETCoreWebApplication.data
(따라서 이에 포함)을 사용해야하지만 오류는 The type or namespace 'ASPNETCoreWebApplication' could not be found [...]
을 반환합니다. 내가 using <project_name>data
을 제거하면 HomeController.cs
에서 ApplicationDbContext
)에 대한
인 이상으로
같은 오류가 내 HomeController.cs
:
Reviews.cs
모델 경우
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ASPNETCoreWebApplication.Data; // "The type or namespace 'ASPNETCoreWebApplication' could not be found [...]"
using <project_name>.Data;
using Microsoft.EntityFrameworkCore;
namespace <project_name>.Controllers
{
public class HomeController : Controller
{
private readonly ApplicationDbContext _context;
public HomeController(ApplicationDbContext context)
{
_context = context;
}
public async Task<IActionResult> Reviews()
{
// "Cannot await 'method group'"
return View(await _context.Reviews.ToListAsync);
}
public IActionResult Error()
{
return View();
}
}
}
가 관련이있을 수 있습니다 : HomeController.cs
에서
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace <project_name>.Models
{
public class Reviews
{
public int Id { get; set; }
public string Date { get; set; }
public string Name { get; set; }
public string Heading { get; set; }
public string Restaurant { get; set; }
public string Comment { get; set; }
public int Rating { get; set; }
public int Agree { get; set; }
public int Disagree { get; set; }
}
}
,
'.ToListAsync()'당신은 괄호를 잊었 –
:'ToListAsync()' – David
그럼 내가 바보처럼 생각하지 않습니다 ... 둘 다 감사합니다 :) – RThomP