/// <summary> /// Removes the specified key. /// </summary> /// <param name="key">The key.</param> /// <returns> /// True if the key was successfully removed from the cache, false otherwise. /// </returns> public override bool Remove(EntityRelationshipModificationCacheKey key) { lock ( _syncRoot ) { RemovePrimaryKey(key); return(base.Remove(key)); } }
/// <summary> /// Adds the primary key. /// </summary> /// <param name="key">The key.</param> private void AddPrimaryKey(EntityRelationshipModificationCacheKey key) { ISet <EntityRelationshipModificationCacheKey> values; if (!_primaryKeyLookup.TryGetValue(key.PrimaryKey.EntityId, out values)) { values = new HashSet <EntityRelationshipModificationCacheKey>( ); _primaryKeyLookup[key.PrimaryKey.EntityId] = values; } values.Add(key); }
/// <summary> /// Adds the specified key. /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <returns> /// True if the specified key/value pair was added; /// False if the specified key/value pair was updated. /// </returns> public override bool Add(EntityRelationshipModificationCacheKey key, IDictionary <long, IChangeTracker <IMutableIdKey> > value) { bool added; lock ( _syncRoot ) { added = base.Add(key, value); AddPrimaryKey(key); } return(added); }
/// <summary> /// Removes the primary key. /// </summary> /// <param name="key">The key.</param> private void RemovePrimaryKey(EntityRelationshipModificationCacheKey key) { ISet <EntityRelationshipModificationCacheKey> values; if (_primaryKeyLookup.TryGetValue(key.PrimaryKey.EntityId, out values)) { values.Remove(key); if (values.Count == 0) { _primaryKeyLookup.Remove(key.PrimaryKey.EntityId); } } }
/// <summary> /// Gets or sets the <see cref="IDictionary{Int64,IChangeTracker}" /> with the specified key. /// </summary> /// <value> /// The <see cref="IDictionary{Int64,IChangeTracker}" />. /// </value> /// <param name="key">The key.</param> /// <returns></returns> public override IDictionary <long, IChangeTracker <IMutableIdKey> > this[EntityRelationshipModificationCacheKey key] { get { return(base[key]); } set { lock ( _syncRoot ) { base[key] = value; RemovePrimaryKey(key); AddPrimaryKey(key); } } }