0

Like in the title, I need to notify to my C# WPF application any changes in the database (there is another app adding data in one table).

I'm using Entity Framework and Linq. The dbms can be different (SQL Server, Oracle, MySQL,...).

I am reading a lot about this and I ask it also here: is there a way yo reach this goal without using polling?

Piero Alberto
  • 3,823
  • 6
  • 56
  • 108
  • 1
    Yes, you have to listen to database events. But that requires very RDBMS-specific configurations and C# code. Which makes this subject far too broad. You could start [here](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx). – Gert Arnold Nov 26 '14 at 08:05
  • There is for example change tracking feature in SQL Server 2008. Do you really need any changes to any table? And how would you process it consequently? Now the question is really too broad. – Vojtěch Dohnal Nov 26 '14 at 08:13
  • @GertArnold your link is only for SQL Server... I said for all dbms – Piero Alberto Nov 26 '14 at 08:35
  • @VDohnal also for your comment.. I said that dbms can be everything from rdbms world – Piero Alberto Nov 26 '14 at 08:36
  • That's why I said *start* here. – Gert Arnold Nov 26 '14 at 09:04

1 Answers1

0

I hope the following link might help you, especially the answer for Event Notifications & Sql server's CLR objects(comments on Redis etc tools) for SQL Server but this may be limited to one or two databases: MsSQL callback function to asp.net website

For Oracle database, the ODP has similar notification mechanism:

http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/changenotification/ChangeNotification.htm

And since the EF providers are different for SQL & Oracle and with very less support for other database, you can have hosted service etc., listening to change notifications and publishing data change event so that the subscriber can take appropriate action like refreshing context or updating cache etc.

Community
  • 1
  • 1
Siva Gopal
  • 3,474
  • 1
  • 25
  • 22
  • but your link are dbms-specific... does it exist something "universal"? – Piero Alberto Nov 26 '14 at 08:36
  • "Universal" is a tough phenomenon AFAIK :-) That's why I mentioned that its applicable to quite a few databases and also EF itself is not universal across most databases unlike other ORMs like NHibernate – Siva Gopal Nov 26 '14 at 08:40
  • @PieroAlberto But you can make service callback approach as a pattern so that whatever databases you work with has similar callback support can call into service to publish notification. – Siva Gopal Nov 26 '14 at 08:43
  • Ok, so, how can I do it with all database supported by EF? what do you mean with service callback? – Piero Alberto Nov 26 '14 at 09:03
  • @PieroAlberto Please take a look a bit more closely at the links provided, where the approach is you will host a web service and provide that service name to the database routine/proc where on data modification that proc will call the web service(this process I called as 'service callback'). I suggest pls take a look at Oracle ODP link, you can understand more on this. – Siva Gopal Nov 26 '14 at 11:00