Exemple #1
0
        /// <summary>
        /// Updates a single object in the object context with data from the data source
        /// </summary>
        /// <param name="mode">A <see cref="RefreshMode"/> value that indicates whether property changes
        /// in the object context are overwritten with property changes from the data source</param>
        /// <param name="entity">The object to be refreshed</param>
        public override void Refresh(RefreshMode mode, object entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (!(entity is BrightstarEntityObject))
            {
                throw new ArgumentException("Expected entity to extend the BrightstarEntityObject class", "entity");
            }
            var beo = entity as BrightstarEntityObject;

            if (beo.Context != this)
            {
                throw new ArgumentException("Entity is not attached to this context", "entity");
            }

            if (mode == RefreshMode.ClientWins)
            {
                _store.Refresh(RefreshMode.ClientWins, beo.DataObject);
                beo.ForceCollectionPropertyUpdates();
            }
            else
            {
                _store.Refresh(RefreshMode.StoreWins, beo.DataObject);
                beo.ClearPropertyCache();
            }
        }