Enitity Framework和长时间运行的对象上下文 [英] Enitity Framework with long-running object context
问题描述
我的一位首席烦恼使用LINQ中的WinForms到SQL(我敢说WPF)是缺乏支持长期运行datacontexts看到<一href="http://blogs.msdn.com/dinesh.kulkarni/archive/2008/04/27/lifetime-of-a-linq-to-sql-datacontext.aspx"相对=nofollow>这里。
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.
问题是,你不能从数据库的更新,你永远只能得到相同的旧记录,直到你扔在DataContext了。这是罚款,一个Web应用程序时,页面只活了毫秒但不与多个绑定控件都粘在旧的datacontext和坐在用户的桌面上。
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.
我的问题是没有EF仍然有这个限制,或者你能获得更新的EF记录没有对象上下文扔掉?
My question is does EF still have this limitation or can you get updated records from EF without throwing away the object context?
推荐答案
您可以使用的 ObjectContext.Refresh 方法来更新现有的方面。
You can use the ObjectContext.Refresh method to update an existing context.
这篇关于Enitity Framework和长时间运行的对象上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!