Notification about Database Change

2019-05-07 22:02发布

问题:

I am trying a scenario in which I want to update my desktop UI running on different PCs with changes committed by any user. For example:

  1. Application1 is installed on PC1, PC2 and PC3.
  2. Assume all PCs are running this application.
  3. Say User 1 on PC1 changes the data and commit to the database
  4. the UI on PC2 and PC3 should be updated with changes without polling or pulling the data from the database.

Can anyone suggest a way to notify my middle tier service about the database change which then I can relay it to all registered client. Will SQL Notification Services or Service Broker notify when the table is changed (inserted/updated/deleted)? Any suggestions will be helpful.

回答1:

Query Notifications does exactly this. You will get a notification when data has changed on the server, you have to query the data again to refresh your UI. A simple implementation would be to use LinqToCache and add an OnInvalidated handler to the CachedQueryOptions object.