从 SqldDependency 返回数据
我正在尝试编写一个使用SqlDependency
的 vb.net 应用程序。当数据添加到数据库时,将触发依赖关系。我想知道是否可以让依赖项返回触发它的数据/查询。
目前我必须让 onchange
事件触发 select 语句来刷新我缓存的数据。是否可以让依赖项返回触发它的新数据
,即将以下内容添加到表中,该表有 2 个字段(id、数据)。
id: 1
data: hello
添加此项后,将触发并
id: 1
data: hello
返回依赖项 onchange 事件
I'm trying to write a vb.net application that usesSqlDependency
. The dependency will be triggered when data is added to the database. I'm wondering if it's possible to have the dependency return the data/query that triggered it.
Currently i have to have the onchange
event trigger a select statement to refresh the data i have cached. Is it possible to just have the dependency return the new data that triggered it
i.e. the following is added to a table, the table has 2 fields (id, data)
id: 1
data: hello
When this is added the dependency onchange event will be fired and
id: 1
data: hello
will be returned
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅http://rusanu.com/2006/06/17/the-神秘通知/ 解释 SqlDependency 如何在幕后工作。无法随通知一起获取数据更改。虽然有一些围绕变更跟踪和变更数据捕获的技术,但由于多种原因,它们不适合监控变更的应用程序。它们用于数据同步(同步框架),并且必须进行更改,这实际上会阻止任何使用它们进行缓存的尝试。
唯一的主动通知更改技术是查询通知,请在我的链接中查看更多详细信息。
See http://rusanu.com/2006/06/17/the-mysterious-notification/ for an explanation how SqlDependency works under the covers. It is not possible to get the data changes along with the notification. While there are technologies around Change Tracking and Change Data Capture, but for a multitude of reasons, they are not appropiate for applications monitoring changes. They are intended for Data Synchronization (Sync Framework) and would have to be pulled for change, which in effect kills any attempt to use them for caching.
The ONLY proactive notification change technology is Query Notificatio, see more details in my link.
不,我认为 SqlDependency 不可能做到这一点。
您可以使用触发器,也可以使用 SQL 2008 中的更改跟踪。
No. I don't think that's possible with SqlDependency.
You could either use triggers, or use the change tracking in SQL 2008.