Exemplo n.º 1
0
 public void Save(bool inTran)
 {
     if (_state == OfflineEntityState.Modified)
     {
         Database.Current.Save(this, inTran);
         _state = OfflineEntityState.Unmodified;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Converts an entity to a tombstone and tracks the change.  It also converts all properties which aren't
        /// part of the key to null/default.
        /// </summary>
        internal void DeleteItem()
        {
            lock (syncRoot)
            {
                CreateSnapshot();

                entityMetadata.IsTombstone = true;
                state = OfflineEntityState.Modified;

                // Clear out all properties
                IEnumerable <PropertyInfo> properties = GetEntityNonKeyProperties();
                foreach (PropertyInfo property in properties)
                {
                    property.SetMethod.Invoke(this, new object[] { null });
                }
            }

            // Notify in case there was any binding
            RaisePropertyChanged("ServiceMetadata");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when the c is submitting items.  It will throw if the item cannot be accepted.
        /// </summary>
        internal void AcceptChanges()
        {
            if (state != OfflineEntityState.Modified)
            {
                // Since this is only called by the c, this should never happen
                throw new InvalidOperationException("Entity is not modified");
            }

            lock (syncRoot)
            {
                if (original != null)
                {
                    if (TickCount != original.TickCount)
                    {
                        throw new InvalidOperationException("Snapshot has changed since the item was last submitted");
                    }
                }

                state    = OfflineEntityState.Saved;
                original = null;
            }
        }
 public void Save(bool inTran)
 {
     if (_state == OfflineEntityState.Modified)
     {
         Database.Current.Save(this, inTran);
         _state = OfflineEntityState.Unmodified;
     }
 }
 public void Load(bool isNew)
 {
     this.isNew = isNew;
     this._state = OfflineEntityState.Unmodified;
 }
 public void SetIsNew()
 {
     this.isNew = true;
     this.EntityState = OfflineEntityState.Modified;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Protected constructor because class is private.  Initial state of created
 /// entities will be Detached.
 /// </summary>
 protected OfflineEntity()
 {
     this.state = OfflineEntityState.Detached;
     //this.syncInfo = new SyncErrorInfo();
     this.entityMetadata = new OfflineEntityMetadata();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Protected constructor because class is private.  Initial state of created
 /// entities will be Detached.
 /// </summary>
 protected OfflineEntity()
 {
     this.state = OfflineEntityState.Detached;
     //this.syncInfo = new SyncErrorInfo();
     this.entityMetadata = new OfflineEntityMetadata();
 }
Exemplo n.º 9
0
        /// <summary>
        /// Converts an entity to a tombstone and tracks the change.  It also converts all properties which aren't
        /// part of the key to null/default.
        /// </summary>
        internal void DeleteItem()
        {
            lock (syncRoot)
            {
                CreateSnapshot();

                entityMetadata.IsTombstone = true;
                state = OfflineEntityState.Modified;

                // Clear out all properties
                IEnumerable<PropertyInfo> properties = GetEntityNonKeyProperties();
                foreach (PropertyInfo property in properties)
                {
                    property.SetMethod.Invoke(this, new object[] { null });
                }
            }

            // Notify in case there was any binding
            RaisePropertyChanged("ServiceMetadata");
        }
Exemplo n.º 10
0
        /// <summary>
        /// Called when the c is submitting items.  It will throw if the item cannot be accepted.
        /// </summary>
        internal void AcceptChanges()
        {
            if (state != OfflineEntityState.Modified)
            {
                // Since this is only called by the c, this should never happen
                throw new InvalidOperationException("Entity is not modified");
            }

            lock (syncRoot)
            {

                if (original != null)
                {
                    if (TickCount != original.TickCount)
                    {
                        throw new InvalidOperationException("Snapshot has changed since the item was last submitted");
                    }
                }

                state = OfflineEntityState.Saved;
                original = null;
            }
        }
Exemplo n.º 11
0
 public void Load(bool isNew)
 {
     this.isNew  = isNew;
     this._state = OfflineEntityState.Unmodified;
 }
Exemplo n.º 12
0
 public void SetIsNew()
 {
     this.isNew       = true;
     this.EntityState = OfflineEntityState.Modified;
 }