如何刷新ObjectContext的高速缓存从数据库? [英] How to refresh ObjectContext cache from db?
本文介绍了如何刷新ObjectContext的高速缓存从数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们是从数据库加载数据:
We are loading data from db:
var somethings = Context.SomethingSet.ToList();
这时,有人中删除或添加背景之外的行。断章取义仍然有删除对象的缓存,因为它不知道自己已被删除。即使我打电话Context.SomethingSet.ToList(),我们的背景下仍包含已删除的对象和导航属性是不正确的。
Then someone deletes or adds rows outside of context. Out context still has caches deleted object, because it doesn't know they were deleted. Even if I call Context.SomethingSet.ToList(), our context still contains deleted objects and navigation properties are not correct.
什么是刷新一整套从数据库的最佳方法是什么?
What is the best method to refresh whole set from database?
推荐答案
在刷新方法是你在找什么:
Context.Refresh(RefreshMode.StoreWins, somethings);
这篇关于如何刷新ObjectContext的高速缓存从数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文