Ejemplo n.º 1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="DbLocalView{TEntity}" /> class for entities
        ///     of the given generic type in the given internal context.
        /// </summary>
        /// <param name="internalContext"> The internal context. </param>
        internal DbLocalView(InternalContext internalContext)
        {
            DebugCheck.NotNull(internalContext);

            _internalContext = internalContext;

            try
            {
                // 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.
                _inStateManagerChanged = true;
                foreach (var entity in _internalContext.GetLocalEntities <TEntity>())
                {
                    Add(entity);
                }
            }
            finally
            {
                _inStateManagerChanged = false;
            }

            _internalContext.RegisterObjectStateManagerChangedEvent(StateManagerChangedHandler);
        }