public void Save(bool inTran) { if (_state == OfflineEntityState.Modified) { Database.Current.Save(this, inTran); _state = OfflineEntityState.Unmodified; } }
/// <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"); }
/// <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 Load(bool isNew) { this.isNew = isNew; this._state = OfflineEntityState.Unmodified; }
public void SetIsNew() { this.isNew = true; this.EntityState = OfflineEntityState.Modified; }
/// <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(); }
/// <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"); }