【发布时间】:2013-08-02 05:21:56
【问题描述】:
我正在通过 MVC 3 应用程序中的 ADO.NET 实体框架访问我的数据库。
我正在通过存储过程更新我的数据库。
但是更改不会在运行时反映出来。我的意思是说我只能在重新启动后才能看到更改。
问题的原因是什么,我该如何避免? 我正在使用存储库模式所以在存储库我的代码看起来像这样
有一个函数可以保存更改
public void SaveNewAnswer(AnswerViewModel answer,string user) {
SurveyAdminDBEntities _entities = new SurveyAdminDBEntities();
_entities.usp_SaveNewAnswer(answer.QuestionId, answer.AnswerName, answer.AnswerText, answer.AnswerOrder, answer.Status, user);
_entities.SaveChanges();
}
数据检索代码
公共 IEnumerableGetMultipleChoiceQuestions(字符串 questionId) {
SurveyAdminDBEntities _entities = new SurveyAdminDBEntities();
_entities.AcceptAllChanges();
_entities.SaveChanges();
return _entities.usp_GetMultipleChoiceQuestions(Int32.Parse(questionId));
}
但是直到我不关闭浏览器的会话并再次运行它时,更改才会反映出来。
请帮忙!
提前谢谢你
【问题讨论】:
-
看看具体有什么变化?
-
您能否向我们展示您用于操作的一些代码?也许你遗漏了一些东西......(但我们无法读懂你的屏幕......)
-
您能否发布映射到
_entities.usp_SaveNewAnswer()的存储过程的SQL 代码?
标签: asp.net-mvc asp.net-mvc-3 entity-framework