Portal.MVC icon indicating copy to clipboard operation
Portal.MVC copied to clipboard

稍微一点并发就报错

Open stoneniqiu opened this issue 7 years ago • 4 comments

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions. {"Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."}

stoneniqiu avatar Mar 18 '17 06:03 stoneniqiu

这个架构不实用。

stoneniqiu avatar Mar 18 '17 06:03 stoneniqiu

操作失败: 无法更改关系,因为一个或多个外键属性不可以为 null。对关系作出更改后,会将相关的外键属性设置为 null 值。如果外键不支持 null 值,则必须定义新的关系,必须向外键属性分配另一个非 null 值,或必须删除无关的对象。

在提供程序连接上启动事务时出错。有关详细信息,请参阅内部异常。

stoneniqiu avatar Mar 18 '17 08:03 stoneniqiu

public ActionResult TestFinishQuestionResp(int qid) { try { var q = _questionService.GetById(qid); q.IsFinished = true; _questionService.UpdateQuestion(q); return Json(1); } catch (Exception e) {

            return Json(e.Message);
        }
    }

function finishQuestion1() { $.post("/Test/TestFinishQuestionResp", { qid: 4 }, function (data) { console.log(data); }); }

run(finishQuestion1,20,100) 这么run个20次就挂了

stoneniqiu avatar Mar 18 '17 08:03 stoneniqiu

建议直接实用 非静态类 new db ,直接封装 CRUD或者业务方法。读取的方法都容易挂。

stoneniqiu avatar Mar 18 '17 08:03 stoneniqiu