2017-07-18 30 views

回答

0

刪除 「使用」。 Controller擁有自己的dispose()方法。您的新代碼將會是...

wipoeeshetronEntities db = new wipoeeshetronEntities() 
var tbllogin = db.masteruserlogindet_tbl.Where(m => m.IsDeleted == 0).ToList(); 
return View(tbllogin); 

這應該工作。

0

您通過調用View返回的對象是一個ActionResult實例,它將沿着管道向下傳遞。但是,由於您正在延遲加載實體(即,不在masterroledet_tbl表上包含或加入),因此您已超出datacontext的範圍(在using語句中)。

解決方案是不離開上下文(這可能會導致內存泄漏問題),而是在離開您的MVC操作之前在您的實體中包含/加入正確的對象。

相關問題