具有长时间运行的对象上下文的实体框架 [英] Entity Framework with long-running object context

查看:54
本文介绍了具有长时间运行的对象上下文的实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Winqs中的Linq to SQL(我敢说WPF)的主要烦恼之一是缺乏对长期运行的数据上下文的支持,请参见此处



问题在于,您无法从数据库获取更新,只有获得相同的旧记录,直到您丢弃数据上下文为止。当网页仅存活几毫秒,但在Winforms应用程序中却没有那么好时,该应用程序具有多个绑定控件,这些控件都固定在旧的datacontext上并位于用户桌面上,因此这对于Web应用程序来说是很好的。 $ b

我的问题是EF是否仍然有此限制,或者您可以在不丢弃对象上下文的情况下从EF获取更新的记录吗?

解决方案

您可以使用 ObjectContext.Refresh 方法进行更新现有的上下文。


One of my chief annoyances with Linq to SQL in WinForms (and I daresay WPF) is the lack of support for long running datacontexts see here.

The problem is that you can't get updates from the database, you only ever get the same old records until you throw the datacontext away. This is fine for a web app when the page is only alive for milliseconds but not so good in a winforms app with multiple bound controls all stuck to the old datacontext and sitting on the users desktop.

My question is does EF still have this limitation or can you get updated records from EF without throwing away the object context?

解决方案

You can use the ObjectContext.Refresh method to update an existing context.

这篇关于具有长时间运行的对象上下文的实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆