private bool GetChangesOnChildCollection(IList trackingItems, bool hasDownstreamChanges, ITrackable item, EntityCollectionProperty <IList> colProp) { // Get changes on child collection var trackingCollChanges = new HashSet <ITrackable>( GetChanges(trackingItems.Cast <ITrackable>()), ObjectReferenceEqualityComparer <ITrackable> .Default); // Set flag for downstream changes hasDownstreamChanges |= trackingCollChanges.Any(); // Memorize only changed items of collection EntityInfo(item).ColNavPropChangedEntities[colProp.Property] = trackingCollChanges; return(hasDownstreamChanges); }
private static void ApplyChangesOnCollectionProperties(TrackingState stateFilter, bool includeState, EntityNavigationProperty navProp, EntityCollectionProperty <IList> colProp, DbContext context, ITrackable item, ObjectVisitationHelper visitationHelper, TrackingState?state = null) { // Apply changes to 1-M and M-M properties filtering by tracking state var count = colProp.EntityCollection.Count; for (int i = count - 1; i > -1; i--) { var trackableChild = colProp.EntityCollection[i] as ITrackable; if (trackableChild != null) { bool condition = includeState ? trackableChild.TrackingState == stateFilter : trackableChild.TrackingState != stateFilter; if (condition) { context.ApplyChanges(trackableChild, item, visitationHelper, navProp.Property.Name, state); } } } }