【发布时间】:2021-05-25 18:23:20
【问题描述】:
对 System.Data.Entity.DbSet 的查询没有反映最新的可能原因是什么 基础数据的变化?我在 Asp.Net MVC 项目中有以下代码:
ShoppingEntities dbcontext = new ShoppingEntities();
var cartID = 200;
Cart check = dbcontext.Cart.Find(cartID);
//here check.quantity equals 9, and the back-end database table shows quantity = 9;
myServiceController.CallSP_UpdateCart(cartID); //back-end stored procedure sets quantity = 10
check = dbcontext.Cart.Find(cartID);
// here check.quantity still equals 9, but the back-end database table shows quantity = 10;
在代码 cmets 中,当我说“后端数据库表显示数量 = xx”时,我指的是我使用 Sql Server Management Studio 在数据库上直接执行的 SQL 查询。我必须使用存储过程来更新后端数据,因为那里有很多复杂的业务逻辑,使用 EF 并不实用。
提前感谢您的帮助。
【问题讨论】:
标签: c# asp.net-mvc entity-framework-6