When using SqlDependency & OnChangeEventHandler in .Net with SQL Server, is it possible (simple?) to discover what data has changed?
+2
A:
You need to run the query again and compare the result obtained with the previous result. How simple it is to detect exactly what changed, depends on what exactly you SELECTed (a single row, all rows in a table, a subset of rows, an aggregate on some/all rows, a join between several tables etc etc). But in general is not simple at all, and is always best to simply run the entire query again, discarding the previous result.
Think at Query Notifications as a means to actively invalidate caches, not as a mean to track changes.
Remus Rusanu
2010-10-19 04:43:41
Thanks, I have a single source of data updates, so I can track them on that end, and possibly do comparisons. However, I think it would probably be best to just refresh the SELECT request for that client.
slomojo
2010-10-19 04:54:39
If you don't use `Take` or `Skip` you can hide this behind a Linq2SQL query: http://code.google.com/p/linqtocache/
Remus Rusanu
2010-10-19 05:04:23