Enitity Framework具有长时间运行的对象上下文 [英] Enitity Framework with long-running object context

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

问题描述

我的主要麻烦之一就是Linq对WinForms(和我敢死的WPF)中的SQL是长期运行的数据指令的缺乏支持,参见 here



问题是你不能从数据库获取更新,只有在你丢弃数据文本之前,才能获得相同的旧记录。对于网页应用程序,当页面仅存在几毫秒时,对于具有多个绑定控件的winforms应用程序而言,该页面仍然存在于旧的数据文本并且位于用户桌面上。



我的问题是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.

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

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