Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7868739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:05:47+00:00 2026-06-03T01:05:47+00:00

Lets say I use a query as below to get a large result set.

  • 0

Lets say I use a query as below to get a large result set.

Select UserID,FirstName, LastName, City, Age from UserInfo where DateDiff(d,GetDate,LastActiveOn)  > 180

Now, I want to cache each object returned by the query and invalidate the object when it changes. So I cast each result for the above result set to User objects (DTO) and then while adding them Cache, add the dependency as follows:

   while (reader.Read())
                {
                    var user = new UserInfo(reader, false);
                    float distance;
                    if (float.TryParse(reader["Distance"].ToString(), out distance))
                    {
                        user.Distance = distance;
                    }
                    //Add user to Cache
                    string userQuery = "SELECT UserID,FirstName,MiddleName,LastName FROM mydb.dbo.UserInfo where UserID=" + user.UserId.ToString();
                    var cacheDependencyCmd = new SqlCommand(userQuery, con);
                    SqlCacheDependency jobSeekerDependency = new SqlCacheDependency(cacheDependencyCmd);
                TimeSpan timeLeftToExpiration = user.LastActive.AddDays(180) - DateTime.Now;

                DateTime itemExpirationDate = DateTime.Now.AddDays(timeLeftToExpiration.Days);


                string key = "u-" + user.UserId.ToString();
                this.Context.Cache.Insert(key,user.UserId.ToString() + user.LastActiveString , jobSeekerDependency, itemExpirationDate, Cache.NoSlidingExpiration, CacheItemPriority.Normal, new CacheItemRemovedCallback(ItemRemovedCallBack));

But this doesn’t seem to work. There are no records in sys.dm_qn_subscriptions. There are no more errors in Event Log (which I was getting yesterday and took appropriate steps to resolve those) Looking at the Sql Profiler I find that the SqlQueryNotification stored procedure is running every 2 minutes or so.

So I am wondering why has the dependency not been created? Is it because I am using a different query to create the dependency?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:05:49+00:00Added an answer on June 3, 2026 at 1:05 am

    The query has to be the same. Basically, the query which invalidates the cache based on dependency is the one which should be used to fetch the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

lets say i use jquery.get to retrive a website to string and how am
In general we use biometrics in computer applications say for authentication. Lets get 2
Lets say I have the query: SELECT Foo FROM Bar Which returns Foo A
I need to kill windows explorer's process (explorer.exe), for that lets say i use
To use as an example: lets say that I have 2 EditText s and
Best to use an example to describe the problem. Lets say I have a
Using mysql its pretty easy to get a page (lets say 20) of threads.
Lets say I have a large number of threads inserting into a mysql database
First, we create classes that represent db entities, ok, done. Let's say we use
Let's say I need to use Python and C++. I can call Python function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.