简体   繁体   English

实体框架DbContext如何从数据库(使用绑定)获取更新?

[英]How does Entity Framework DbContext get updates from database (with Binding)?

I'm trying to develop a multi-user application that basically would have a list of some items. 我正在尝试开发一个多用户应用程序,该应用程序基本上将包含一些项的列表。 Each user is doing some CRUD operations to this list. 每个用户都对此列表执行某些CRUD操作。 I need that users see changes to list when other users make some changes. 我需要用户在其他用户进行某些更改时看到要列出的更改。

I thought binding is what I need, but according to information in msdn, DbContext is a Unit of Work/Repository... does this mean that it is not possible for DbContext to read updates from data base automatically? 我认为绑定是我所需要的,但是根据msdn中的信息,DbContext是工作单元/存储库...这是否意味着DbContext无法自动从数据库读取更新?

http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext(v=vs.103).aspx http://msdn.microsoft.com/en-us/library/system.data.entity.dbcontext(v=vs.103).aspx

Is there a way to get the desired result using Entity Framework? 有没有一种方法可以使用实体框架获得所需的结果?

[EDIT] Is the only way to get updates from database is to use timer with additional code to reload data from database? [EDIT]从数据库获取更新的唯一方法是使用带有附加代码的计时器从数据库中重新加载数据吗? Is this the only option for real-time apps? 这是实时应用程序的唯一选择吗?

DataBinding means a binding between UI and your Objects and not Objects to DataBase. DataBinding表示UI和您的对象之间的绑定,而不是到数据库的对象之间的绑定。

You need to call a Reload/Refresh method to get the latest database values. 您需要调用Reload / Refresh方法来获取最新的数据库值。 Like this: http://stackoverflow.com/questions/16872305/i-do-not-understand-how-ef5-dbcontext-entryentity-reload-method-is-supposed 像这样: http//stackoverflow.com/questions/16872305/i-do-not-understand-how-ef5-dbcontext-entryentity-reload-method-is-supposed

(See comments) (看评论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM