示例#1
0
        /// <summary>
        /// Updates any Cache Objects that are associated with this entity
        /// </summary>
        /// <param name="entityState">State of the entity.</param>
        /// <param name="dbContext">The database context.</param>
        public void UpdateCache(EntityState entityState, Rock.Data.DbContext dbContext)
        {
            // Make sure CampusCache.All is cached using the dbContext (to avoid deadlock if snapshot isolation is disabled)
            var campusId = this.GetCampusId(dbContext as RockContext);

            // CampusCache has a CampusLocation that could get stale when Location changes, so refresh the CampusCache for this location's Campus
            if (this.CampusId.HasValue)
            {
                CampusCache.UpdateCachedEntity(this.CampusId.Value, EntityState.Detached);
            }

            // and also refresh the CampusCache for any Campus that uses this location
            foreach (var campus in CampusCache.All(dbContext as RockContext).Where(c => c.LocationId == this.Id))
            {
                CampusCache.UpdateCachedEntity(campus.Id, EntityState.Detached);
            }
        }
示例#2
0
 /// <summary>
 /// Updates any Cache Objects that are associated with this entity
 /// </summary>
 /// <param name="entityState">State of the entity.</param>
 /// <param name="dbContext">The database context.</param>
 public void UpdateCache(EntityState entityState, Rock.Data.DbContext dbContext)
 {
     CampusCache.UpdateCachedEntity(this.Id, entityState);
 }
示例#3
0
 /// <summary>
 /// Updates any Cache Objects that are associated with this entity
 /// </summary>
 /// <param name="entityState">State of the entity.</param>
 /// <param name="dbContext">The database context.</param>
 public void UpdateCache(EntityState entityState, Rock.Data.DbContext dbContext)
 {
     // CampusCache may get stale a if CampusSchedule is modified
     CampusCache.UpdateCachedEntity(this.CampusId, EntityState.Modified);
 }