/// <summary> /// Parses the relationship. /// </summary> /// <param name="relationship">The relationship.</param> /// <param name="invalidObjects">The invalid objects.</param> private void ParseRelationship(IChangeTracker <IMutableIdKey> relationship, ISet <long> invalidObjects) { ///// // Argument check. ///// if (relationship == null) { return; } if (invalidObjects == null) { ///// // Reinitialize the set. ///// invalidObjects = new HashSet <long>( ); } if (relationship.Flushed) { ///// // All entities are invalid. ///// foreach (var modification in relationship.Where(pair => pair != null)) { invalidObjects.Add(modification.Key); } return; } ///// // Process the added relationships. ///// if (relationship.Added != null && relationship.Added.Any( )) { ///// // All added entities are invalid. ///// foreach (var modification in relationship.Added.Where(pair => pair != null)) { invalidObjects.Add(modification.Key); } } ///// // Process the removed relationships. ///// if (relationship.Removed != null && relationship.Removed.Any( )) { ///// // All removed entities are invalid. ///// foreach (var modification in relationship.Removed.Where(pair => pair != null)) { invalidObjects.Add(modification.Key); } } }
/// <summary> /// Removes the specified item. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public bool Remove(TEntity item) { if (item == null) { return(false); } Precheck( ); IMutableIdKey[] matches = _tracker.Where(pair => pair.Key == item.Id).ToArray( ); return(matches.Aggregate(false, (current, match) => current & _tracker.Remove(match))); }