예제 #1
0
 public DelayedValueChange(Entity entity, object oldEntity, object newEntity, Attribute newAttr, Attribute oldAttr)
 {
     Entity     = entity;
     _oldEntity = oldEntity;
     _newEntity = newEntity;
     NewAttr    = newAttr;
     OldAttr    = oldAttr;
 }
예제 #2
0
 public ValueChange(Entity entity, Attribute attribute, object entityObj, object oldValue, object newValue)
 {
     Entity    = entity;
     Attribute = attribute;
     OldValue  = oldValue;
     NewValue  = newValue;
     EntityObj = entityObj;
 }
예제 #3
0
 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")
     });
예제 #4
0
 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);
     }
 }
예제 #5
0
        /// <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);
        }
예제 #6
0
        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) });
        }
예제 #7
0
 public ColumnDefinition(Entity entity, Attribute attribute)
 {
     _entity    = entity;
     _attribute = attribute;
 }