Exemplo n.º 1
0
        protected override void RelCreationChange(EntityChangeRelCreation item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity);

            if (temp.Any(p => p is EntityChangeRelCreation == false))
            {
                throw new InvalidOperationException("Unable to schedule a relationship creation for an entity already tracked.");
            }
            if (temp.Any() && temp.Any(p => !p.Equals(item)))
            {
                throw new InvalidOperationException("Unable to schedule a relationship creation. Already tracked for another source-destination pair.");
            }

            if (ChangeLog.Any(p => p is EntityChangeNodeDeletion && p.Entity == item.Source) ||
                item.Source.EntityId == null && !ChangeLog.Any(p => p is EntityChangeNodeCreation && p.Entity == item.Source))
            {
                throw new ArgumentException("Invalid source node");
            }
            if (ChangeLog.Any(p => p is EntityChangeNodeDeletion && p.Entity == item.Destination) ||
                item.Destination.EntityId == null && !ChangeLog.Any(p => p is EntityChangeNodeCreation && p.Entity == item.Destination))
            {
                throw new ArgumentException("Invalid destination node");
            }

            if (!temp.Any())
            {
                ChangeLog.Add(item);
            }
        }
Exemplo n.º 2
0
 protected abstract void RelCreationChange(EntityChangeRelCreation item);
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            EntityChangeRelCreation other = obj as EntityChangeRelCreation;

            return(base.Equals(obj) && other?.Source == Source && other?.Destination == Destination);
        }