views:

179

answers:

1

I been trying to get sqlcachedependecy working, but it doesn't appear to work

I got the proper settings in my web.config and also global.asa, however when I run this query and the changes are made to the database from either with in or outside the web site the cached objects are not updated please someone help? I know its not because this query is querying a view, because I tested this using straight SqlDependecy and the notification works fine.

  public IQueryable<VictoryList> GetVictoryList()
   {
                string cacheKey = HttpContext.Current.User.Identity.Name + "victoryCacheKey";
                IQueryable<VictoryList> cachednews = (IQueryable<VictoryList>)HttpContext.Current.Cache.Get(cacheKey);

                if (cachednews == null)
                {

                    var results = from v in _datacontext.ViewVictoryLists
                                  orderby _datacontext.GetNewId()
                                  select new VictoryList
                                  {
                                      MemberID = v.MemberID,
                                      Username = v.Aspnetusername,
                                      Location = v.Location,
                                      DaimokuGoal = v.DaimokuGoal,
                                      PreviewImageID = v.PreviewImageID,
                                      TotalDaimoku = v.TotalDaimoku,
                                      TotalDeterminations = v.TotalDeterminations,
                                      DeterminationID = v.DeterminationID,
                                      DeterminationName = v.DeterminationName
                                  };
                    results = results.ToList().AsQueryable();
                    SqlCacheDependencyAdmin.EnableNotifications(_datacontext.Connection.ConnectionString);
                    SqlCacheDependency dependency =
                     new SqlCacheDependency(_datacontext.GetCommand(results) as SqlCommand);



                    HttpContext.Current.Cache.Insert(cacheKey, results, dependency);

                    return results;
                }
                return cachednews;
   }
+1  A: 

According to the stated Limitations for creating a query for notification, listed at msdn...

The statement must not reference a view.

duckworth
Thanks I did bump across this ... and I did have it working with the view (sort of) apparently it doesn't work consistantly.
dswatik