/// <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(EntityFieldModificationCacheKey key) { lock ( _syncRoot ) { RemovePrimaryKey(key); return(base.Remove(key)); } }
/// <summary> /// Adds the primary key. /// </summary> /// <param name="key">The key.</param> private void AddPrimaryKey(EntityFieldModificationCacheKey key) { ISet <EntityFieldModificationCacheKey> values; if (!_primaryKeyLookup.TryGetValue(key.PrimaryKey.EntityId, out values)) { values = new HashSet <EntityFieldModificationCacheKey>( ); _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(EntityFieldModificationCacheKey key, IEntityFieldValues 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(EntityFieldModificationCacheKey key) { ISet <EntityFieldModificationCacheKey> 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,Object}" /> with the specified key. /// </summary> /// <value> /// The <see cref="IDictionary{Int64,Object}" />. /// </value> /// <param name="key">The key.</param> /// <returns></returns> public override IEntityFieldValues this [EntityFieldModificationCacheKey key] { get { return(base[key]); } set { lock ( _syncRoot ) { base[key] = value; RemovePrimaryKey(key); AddPrimaryKey(key); } } }