Beispiel #1
0
        /// <summary>
        /// Removes the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="suppressFullInvalidation">if set to <c>true</c> [suppress full invalidation].</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">key</exception>
        public bool Remove(EntityRelationshipCacheTypeKey key, bool suppressFullInvalidation = false)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                IEntity entity = EntityCache.Instance.Get(key.EntityId);

                if (entity != null)
                {
                    entityTypeContext.Merge(key.EntityId, entity.TypeIds);
                }

                bool result = ProviderRemove(key);

                HashSet <long> typeIds = entityTypeContext.Get(key.EntityId);

                if (!suppressFullInvalidation)
                {
                    var message = new EntityRelationshipCacheMessage( );
                    message.SuppressFullInvalidation = suppressFullInvalidation;
                    message.RemoveTypeKeys.Add(new SerializableEntityRelationshipCacheTypeKey(SerializableEntityId.Create(key.EntityId, typeIds), key.Direction, key.TypeId));

                    MessageChannel.Publish(message, PublishOptions.FireAndForget, false, MergeMessages);
                }

                return(result);
            }
        }
        /// <summary>
        ///     Removes the specified key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public override bool Remove(long key)
        {
            using (var entityTypeContext = new EntityTypeContext( ))
            {
                IEntity entity = EntityCache.Instance.Get(key);

                if (entity != null)
                {
                    entityTypeContext.Merge(key, entity.TypeIds);
                }

                return(base.Remove(key));
            }
        }