Are there any implications of using SqlDependency and LINQ to SQL together. Or do we have to take care of some things specially to make them work properly?
In our application we are using LINQ to SQL as an ORM and business logic is in the Stored Procedures. We cache the output of the SPs and create SQLDependency. Whenever the output of the SPs change the cache gets invalidated.
Our code so far was working fine in Dev, Test and QA but recently it stopped working in QA and logs suggest that the error is coming from SqlDependency.Start(ConnStr) which is executed in the global.asax file in Application Start block.
The error is as follows: Message : When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance.
But I do not understand that when the SqlDependency.Start() is already executed in Application Start why does it throws exception afterwards when the SPs are executed.
Can anyone开发者_StackOverflow中文版 throw some light on this problem?
As SQLDependency is permissions-dependent - did permissions change on the server?
(They probably shouldn't have - but they may!)
make sure all the permissions are set properly, below list of all necessary permissions that i applied to make it working.
-- Permissions
GRANT CREATE PROCEDURE to [testUser]
GRANT CREATE QUEUE to [testUser]
GRANT CREATE SERVICE to [testUser]
----
GRANT REFERENCES on CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]
to [testUser]
GRANT RECEIVE ON QueryNotificationErrorsQueue TO [testUser]
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [testUser]
GRANT CONTROL ON SCHEMA::[dbo] TO [testUser]
GRANT IMPERSONATE ON USER::DBO TO [testUser]
精彩评论