Question

I want to have a column specific SqlCacheDependency.

The Row Specific SqlCacheDependency is valid but i dont know how can i make Column Specific SqlCacheDependency

Example:

The query:

SELECT 
[Extent1].[Price] AS [Price] 
FROM [dbo].[Products] AS [Extent1]
where [Extent1].[ID] = 31167

causes the notification if the Row with ID = 31167 changes.

But the problem is that the Cache becomes invalid if any of the column of that row get changed but i want the cache becomes invalid only if Price of the ID 31167 get changed

I googled it for long but don't get any help.

Thanks

Any help is appreciated.

Was it helpful?

Solution

SqlDependency (which is used by SqlCacheDependency) does not offer column-level control. The semantics of the change notifications is that they are sent if a row returned or used by the query "might have changed."

If this is an important feature for you, you would need to implement it yourself, probably using triggers and either Service Broker to queue and deliver the change notifications, or through polling as with the old-style table-based notifications in .NET.

Another possibility might be to pull your columns of interest off into a separate table (either an explicit copy or one maintained with triggers) or a new table that you then join to the original one with views or SPs. Each row would then only contain the column you're interested in (plus the PK).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top