public void CommitChanges(PersistDepth persistDepth) { this.CommitChildren(persistDepth); if (this.State == ObjectState.Deleted) { this.instance = null; } else { if (this.initial == InitialState.Inserted && this.entity.KeyType == KeyType.Auto) { // InitialState Bug-Fix by Gerrod Thomas (http://www.Gerrod.com) this.initial = InitialState.Unchanged; EntityKey entityKey = new EntityKey(this.context, this.EntityObject, this.IsPersisted); this.context.StartTracking(entityKey, this); } this.StartTracking(InitialState.Unchanged); } }
/// <summary> /// Determines if this EntityKey is equal to another object. The EntityKey is equal to another /// EntityKey if all the elements compare equal using using IComparable<T>.Equals or object.Equals. /// </summary> /// <param name="other">EntityKey to compare with for equality.</param> /// <returns>True if the EntityKey are equal. False if the EntityKey are not equal.</returns> public bool Equals(EntityKey other) { if (this.type != other.type) return false; object[] thisValue = this.value as object[]; if (thisValue != null) { object[] otherValue = other.value as object[]; // this has an array of key elements, the other must as well and of the same length if (otherValue == null || thisValue.Length != otherValue.Length) return false; for (int i = 0; i < thisValue.Length; i++) { if (!EqualOneValue(thisValue[i], otherValue[i])) return false; } return true; } return EqualOneValue(this.value, other.value); }
internal bool IsTracked(object entityObject) { EntityKey entityKey = new EntityKey(this, entityObject, true); return(this.instances.Contains(entityKey)); }
internal void StartTracking(EntityKey entityKey, Instance instance) { this.instances[entityKey] = instance; }
public object GetObjectKey(object entityObject) { EntityKey entityKey = new EntityKey(this, entityObject, true); return(entityKey.Value); }