开发者

Cache drop if query has WHERE Clause

I am using SqlDependency and CacheManager class(Enterprise library Cachcing block) to create a cache in one of vb.net project.

I have registerd

OnDependencyChanged(ByVal sender As Object, ByVal e As SqlNotificationEventArgs) 

method to get the notification back from Sql Server 2005.

Now the problem is, if the query does not contains any WHERE clause then cache gets created successfully but if I add a where clause in my query then OnDependencyChanged() method gets notification as soon as cache is created.

I need suggestion whether it is possible to have a WHERE clause in the query that is being used for caching. My query is (with WHERE Clause):

SELECT [DATABASES_ID]  
      ,[DATABASENAME]
      ,[SER开发者_Python百科VERNAME]
  FROM [dbo].[DATABASES]
  WHERE datediff(dd,getdate(), [DATECREATED]) <=0

Thanks Brijesh


Check out this article outlying the limitations of SQLDepenency queries

http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx

Specifically of Note:

The statement must not use any nondeterministic functions, including ranking and windowing functions.

GETDATE() being one such function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜