如何清除Entity Framework 1.0中ObjectContext的内容
是否有手动清除/重置 ObjectContext 回到其初始状态的方法?请注意,我不能只是实例化一个新上下文。
这是使用 1.0 版本的实体框架。
谢谢
Is there a method of manually clearing/resetting an ObjectContext back to its initial state? Note that I can't just instantiate a new context.
This is using the 1.0 version of the Entity Framework.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ObjectContext 是一个短暂的对象,不应该像这样被缓存。正常使用应该是这样的:
ObjectContext is meant to be a short-lived object, it shouldn't be cached like that. Normal usage should look like:
您可以尝试调用 Detach 方法对于加载到上下文的每个实体。
You can try to call the Detach method for each entity that was loaded to the context.