src/Shared/EntityFramework/Internal/DbLocalView`.cs
// <summary>
// Handles events from the state manager for entities entering, leaving, or being marked as deleted.
// The local view is kept in sync with these changes.
// </summary>
// <param name="sender"> The sender. </param>
// <param name="e">
// The <see cref="System.ComponentModel.CollectionChangeEventArgs" /> instance containing the event data.
// </param>
Handles events from the state manager for entities entering, leaving, or being marked as deleted.
The local view is kept in sync with these changes.
Handles events from the state manager for entities entering leaving or being marked as deleted . The local view is kept in sync with these changes .
private void StateManagerChangedHandler(object sender, CollectionChangeEventArgs e)
        {
            Debug.Assert(
                e.Action == CollectionChangeAction.Add || e.Action == CollectionChangeAction.Remove,
                "Not expecting Action of Refresh from the state manager");
            try
            {
                _inStateManagerChanged = true;
                var entity = e.Element as TEntity;
                if (entity != null)
                {
                    if (e.Action == CollectionChangeAction.Remove
                        && Contains(entity))
                    {
                        Remove(entity);
                    }
                    else if (e.Action == CollectionChangeAction.Add
                             && !Contains(entity))
                    {
                        Add(entity);
                    }
                }
            }
            finally
            {
                _inStateManagerChanged = false;
            }
        }
private void StateManagerChangedHandler ( object sender , CollectionChangeEventArgs e ) { Debug . Assert ( e . Action == CollectionChangeAction . Add || e . Action == CollectionChangeAction . Remove , " " ) ; try { _inStateManagerChanged = true ; var entity = e . Element as TEntity ; if ( entity != null ) { if ( e . Action == CollectionChangeAction . Remove && Contains ( entity ) ) { Remove ( entity ) ; } else if ( e . Action == CollectionChangeAction . Add && ! Contains ( entity ) ) { Add ( entity ) ; } } } finally { _inStateManagerChanged = false ; } }
Handles events from the state manager for entities entering, leaving, or being marked as deleted.
Handles events from the state manager for entities entering leaving or being marked as deleted .
// Set a flag to prevent changes we're making to the ObservableCollection based on the // contents of the state manager from being pushed back to the state manager.
sender
object
None
e
CollectionChangeEventArgs
The  instance containing the event data.
The instance containing the event data .