且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

sqldependency vs sqlnotificationrequest。哪个更好用?

更新时间:2023-02-13 18:27:37

SqlNotificationRequest 在内部使用 SqlDependency 订阅查询事件。我会在 SqlDependency 上使用 SqlNotificationRequest ,因为大部分布线已经完成,这意味着可以更轻松地使用通知。从技术上讲,因为一个在内部使用另一个,两者没有区别,只有一个有很多设置工作。
SqlNotificationRequest uses SqlDependency internally to subscribe to query events. I would use SqlNotificationRequest over SqlDependency because most of the wiring is already done and it is meant to make using notifications easier. Technically because one uses the other internally, there is no difference in the two, just one has a lot of the setup work done.


In case of SQLDependency/SQLNotificationRequest you require separate queue per process. If your different processes listen on the same queue then event notification is not guaranteed. But this is how it is right now.