SqlDependency not working selectively?
I'm trying to observe some data in my SQL server express 2005 like this:
SqlDependency.Stop(connectionString);
SqlDependency.Start(connectionString);
using (var con = new SqlConnection(connectionString))
{
con.Open();
var queryString = "SELECT [Name] FROM [dbo].[Persons]";
var command = new SqlCommand(queryString, con);
var dependency = new SqlDependency(command);
dependency.OnChange += OnQueryChanged;
command.ExecuteReader();
}
The problem is that I'开发者_JAVA百科m only interested in a callback if the column "Name" changes. But OnQueryChanged is also called if another column of the table "Persons" is changed, like this:
var context = new Entities();
context.Persons.First().Street = "Foo";
context.SaveChanges();
Is this the intended behavior of SqlDependency or do I make a mistake in its usage?
It seems that it is only possible to observe whole tables (http://social.msdn.microsoft.com/Forums/en-US/sqlservicebroker/thread/acb94617-bafc-4e28-bc63-ddfd23ab2379) - is this correct?
精彩评论