4

Following this tutorial I was able to make an index view refresh itself when the corresponding table on the database changes. The problem occurs when I want to detect changes on a page with an index view that displays data from other tables, like

db.Vehicles.Include(v => v.Model)

On those scenarios it seems like the database sends notifications of events one after another, calling the method "DispatchToClient()" of the tutorial, making the view refresh itself again and again unnecessarily.

I am very new to these technologies, so any help or advice would be appreciated.

Community
  • 1
  • 1
Lorena
  • 135
  • 8

1 Answers1

0

If you aren’t aware, the SqlDependency detects when query results differ from those originally retrieved. You would have to interrogate the code in the event OnSqlDependencyChange to essentially intercept and determine if there were changes by looking at the SqlNotificationEventArgs.

https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlnotificationinfo(v=vs.110).aspx

William Xifaras
  • 5,212
  • 2
  • 19
  • 21