views:

469

answers:

2

Hi all.

I have a WCF service that needs to notify it's clients when changes occur to the database (sql server 2005). This is relatively easy accomplished, as long as I find a way to notify my service of any changes. I can probably create a database trigger on a table and have that trigger start a small service client that notifies my service, but I'm wondering if there's a better way to do this? It would be a viable solution to have the service poll the database for changes, but I'm not sure on the best way to do it (and sendign a notification to my service would be preferred).

As the relevant updates apply only to a certain part of the database, I was also wondering if it's also possible to link such a trigger (or other mechanism) to a database diagram.

All help is appreciated! rinze

+1  A: 

If your database is SQL Server 2005 and above you can try this solution: Remove pooling for data changes from a WCF front end.

As a side note, never call external processes from a trigger, don't make web calls from a trigger. Is a guaranteed recipe for disaster.

Update

For those interested in mixing Query Notifications with LINQ to SQL I recommend Using SQLDependency objects with LINQ.

Remus Rusanu
OK, this blog does (almost) exactly what I'm doing here. As I'm using LINQ to SQL, it's a bit less straightforward, but shouldn't be a problem. Do you know if it's possibly to add a dependency on a database diagram (or a view, to simulate it)?Thanx for the link!
Syg
I haven't thought about using LINQ and SqlDependency in combination. I'll see how this can be achieved and post back.
Remus Rusanu
See my update, Ryan Dunn has already blogged about SqlDependency and Linq2sql.
Remus Rusanu