第三方数据库修改后的实体刷新 [英] Entity refresh after third party database modification

查看:88
本文介绍了第三方数据库修改后的实体刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有一个实体任务,其属性为Progress(int 0..100)。

任务表是由另一个应用程序直接更新(使用其他语言)。



我想进行自动刷新,在我的实体任务中引发notifypropertychanged。



我试图将context.refresh(storewin,object)与后台工作者一起使用,但每次都会引发notifypropertychanged(即使没有属性发生变化=>纯重载)。

我不想在循环中查询,(只有在没有解决方案的情况下)。



有任何建议吗?



谢谢

Hello,

I have an entity Task with a property Progress (int 0..100).
The task table is updated directly by another application (with another language).

I would like to make a auto refresh which raise notifypropertychanged on my entity Task.

I tried to used context.refresh(storewin, object) with a background worker but it raises notifypropertychanged every time (even if no property has changed => pure reload).
And i dont want to query in loop, (only if there''s no solution).

Any suggestion please?

Thanks

推荐答案

实体框架不支持SQL通知,因此使用完全EF对象和方法别无选择轮询数据。这也意味着,是的,即使值没有改变,NotifyPropertyChanged事件也会每次触发。这是因为价值在内部发生变化。 ojbect EF跟踪被删除并从后备存储数据重新创建,因此值从null或0变为从数据库返回的任何值。



另一个选项是去外部EF并直接查询表或使用SQL Server Notification Services并订阅它。
Entity Framework doesn''t support SQL Notifications, so using a entirely EF objects and methods leaves you no choice but to poll for the data. This also means that, yes, the NotifyPropertyChanged event will fire every single time even though the value doesn''t change. That''s because the value DOES change internally. The ojbect EF is tracking gets dropped and recreated from the backing store data, so the value changes from null or 0 to whatever was returned from the database.

The other option is to go outside EF and query the table directly or use SQL Server Notification Services and subscribe to that.


这篇关于第三方数据库修改后的实体刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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