-1
이것은 알림 컨트롤러의 내 색인 작업 코드입니다.asp.net mvc에서 System.Data.Entity.Core.EntityCommandExecutionException을 피하는 방법?
public ActionResult Index()
{
//gets the current user
ApplicationUser currentUser = System.Web.HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());
//checks if the user is logged in
bool val1 = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
if (val1 == false)
{
return RedirectToAction("Login", "Account");
}
var myNotif = db.Notifications.Where(s => s.User1_Id == currentUser.Id || s.User2_Id == currentUser.Id).Where(s => s.Active_Status != currentUser.Id);
ViewBag.Autobots = new NotificationStatus[myNotif.Count()];
int i = 0;
foreach(var item in myNotif)
{
ViewBag.Autobots[i].name = db.Users.Where(x => item.Active_Status == x.Id).First().FirstName + " " + db.Users.Where(x => item.Active_Status == x.Id).First().LastName;
i++;
}
return View(myNotif.ToList());
}
private class NotificationStatus
{
string name;
}
여기에이 오류가 표시됩니다. 어떻게 피할 수 있습니까? 볼 데이터를 보내려고하므로 문자열 배열을 사용하고 있습니다. 내 Linq 쿼리가 잘못된 곳입니까? enter image description here
안녕하세요, 내부 예외를 살펴보십시오. –
어떻게하면됩니까? –
첨부 한 이미지에 링크 복사 예외 세부 사항이 클립 보드에 있습니다. 그것을 클릭 한 다음 텍스트 편집기에 붙여 넣으십시오. –