Db.savechanges()行在EF中冻结 [英] Db.savechanges() line freezes in EF
问题描述
当db.savechanges()行到达断点时。什么都没发生。 catch块中没有错误。浏览器只是冻结而不保存数据。我在asp.net mvc上使用oracle。
我没有得到浏览器或VS 15的响应。我得到的只是浏览器标签中的加载标志。我离开了10分钟。还有什么你想知道的?我在运行之前清除了缓存。 _userService.Add(模型);这行完美但后者_userService.AddUserPermission(permission);不工作
我尝试过:
When the line db.savechanges() hits the breakpoint. Nothing happens. no errors in the catch block. The browser just freezes and data is not saved. I am using oracle with asp.net mvc.
I get no response from the browser or VS 15. All i get is the loading sign in the browser tab. i left it for 10 mins. what else do u want to know? i have cleared my cache before running this. _userService.Add(model); This line works perfectly but the latter "_userService.AddUserPermission(permission);" does not work
What I have tried:
public ResponseResult AddUserPermission(USER_PERMISSION permission)
{
try
{
_db.Entry(permission).State = EntityState.Modified;
_db.SaveChanges();
return new ResponseResult();
}
catch (Exception ex)
{
//return new ResponseResult();
return new ResponseResult(ResutlType.Error, ex.Message);
}
}
[HttpPost]
[CustomAuthorize("Admin")]
public ActionResult Create(USER model)
{
try
{
string moduleId = Request.Form["ModuleId"];
string isSelected = Request.Form["IsSelected"];
model.DATE_CREATED = DateTime.Now;
model.DATE_UPDATED = DateTime.Now;
model.STATUS = (int)Status.Active;
var userPermission = processPermissionData(moduleId, isSelected);
//userPermission contains a list of permissions which i am trying to save
_userService.Add(model);
foreach (var permission in userPermission)
{
_userService.AddUserPermission(permission);
}
return RedirectToAction("Index");
}
catch
{
return View();
}
}
推荐答案
您的项目中可能有很多断点。只需从visual studio中删除所有断点,然后在您想要查看更改或数据的位置留下一个断点。
You may have a lot of break points in your project. Just remove all break points from visual studio and leave a single break point where you want to see the changes or data.
这篇关于Db.savechanges()行在EF中冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!