public DelayedValueChange(Entity entity, object oldEntity, object newEntity, Attribute newAttr, Attribute oldAttr) { Entity = entity; _oldEntity = oldEntity; _newEntity = newEntity; NewAttr = newAttr; OldAttr = oldAttr; }
public ValueChange(Entity entity, Attribute attribute, object entityObj, object oldValue, object newValue) { Entity = entity; Attribute = attribute; OldValue = oldValue; NewValue = newValue; EntityObj = entityObj; }
private IEnumerable <IValueChange> ExtractRelationChanges(Attribute attribute) { Trace.Assert(attribute.Relation != null); return(attribute.Relation switch { OneToMany oneToMany => ExtractOneToManyChanges(oneToMany), ManyToOne manyToOne => ExtractManyToOneChanges(manyToOne), ManyToMany manyToMany => ExtractManyToManyChanges(manyToMany), _ => throw new NotSupportedException("Relation type is not supported") });
public override int GetHashCode() { unchecked { var hashCode = (Attribute != null ? Attribute.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OldValue != null ? OldValue.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NewValue != null ? NewValue.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Replaces the related keys of this CacheEntry /// Related keys are used to determine whether an update to a OneToMany or ManyToMany relation has been made /// </summary> /// <param name="attribute"></param> /// <param name="keys"></param> /// <exception cref="Exception"></exception> public void ReplaceRelatedKeys(Attribute attribute, IEnumerable <object> keys) { if (!attribute.IsEntityType) { throw new Exception("Attribute must be a relation in order to associate it with related keys"); } var set = _relatedKeys.GetOrInsert(attribute.Name, new SortedSet <object>()); set.Clear(); set.UnionWith(keys); }
private IEnumerable <IValueChange> ExtractSimpleChanges(Attribute attribute) { var oldValue = OriginalValues[attribute.Name]; var newValue = attribute.InvokeGetter(Object); if (Equals(oldValue, newValue)) { return(new IValueChange[0]); } if (Entity.PrimaryKeyAttribute == attribute) { throw new ArgumentException( "Primary key updates are not supported consider deleting the entity and inserting a new one"); } return(new[] { new ValueChange(Entity, attribute, Object, oldValue, newValue) }); }
public ColumnDefinition(Entity entity, Attribute attribute) { _entity = entity; _attribute = attribute; }