예제 #1
0
        protected override void NodeUpdateChange(EntityChangeNodeUpdate item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity).ToList();

            if (!temp.Any() && item.Entity.EntityId == null)
            {
                throw new InvalidOperationException("Unable to locate entity. It must be tracked or have an EntityId.");
            }

            if (temp.Any(p => p is EntityChangeNodeDeletion))
            {
                throw new InvalidOperationException("Unable to update an entity scheduled for deletion");
            }

            if (temp.Any(p => p is EntityChangeNodeCreation))
            {
                return;
            }

            if (temp.Any(p => p.Inverse != null && p.Inverse.Equals(item)))
            {
                ChangeLog.Remove(item);
            }
            else
            {
                if (temp.Any(p => (p as EntityChangeNodeUpdate)?.Property == item.Property))
                {
                    ChangeLog.RemoveAll(p => temp.Contains(p) && (p as EntityChangeNodeUpdate)?.Property == item.Property);
                }
                ChangeLog.Add(item);
            }
        }
예제 #2
0
        protected override void ConnectionMergeChange(EntityChangeConnectionMerge item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity && p is EntityChangeConnectionMerge).ToList();

            ChangeLog.RemoveAll(p =>
                                temp.Contains(p) &&
                                ((p as EntityChangeConnectionMerge).Source != item.Source || (p as EntityChangeConnectionMerge).Destination != item.Destination));

            EntityChangeConnectionMerge existing = temp.FirstOrDefault(p => (p as EntityChangeConnectionMerge).Source == item.Source && (p as EntityChangeConnectionMerge).Destination == item.Destination) as EntityChangeConnectionMerge;

            if (existing == null)
            {
                ChangeLog.Add(item);
            }
            else
            {
                existing.Order = item.Order;
            }
        }
예제 #3
0
        protected override void RelDeletionChange(EntityChangeRelDeletion item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity).ToList();

            if (!temp.Any() && item.Entity.EntityId == null)
            {
                return;
            }

            if (temp.Any(p => p is EntityChangeRelCreation || p is EntityChangeConnectionMerge))
            {
                ChangeLog.RemoveAll(p => temp.Contains(p));
            }
            else
            {
                ChangeLog.RemoveAll(p => temp.Contains(p));
                ChangeLog.Add(item);
            }
        }
예제 #4
0
        protected override void NodeDeletionChange(EntityChangeNodeDeletion item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity).ToList();

            if (!temp.Any() && item.Entity.EntityId == null)
            {
                throw new InvalidOperationException("Unable to locate entity. It must be tracked or have an EntityId.");
            }

            if (temp.Any(p => p is EntityChangeNodeCreation))
            {
                ChangeLog.RemoveAll(p => temp.Contains(p));
            }
            else
            {
                ChangeLog.RemoveAll(p => temp.Contains(p));
                ChangeLog.Add(item);
            }

            foreach (EntityChangeRelCreation rel in ChangeLog.Where(p => p is EntityChangeRelCreation && (((EntityChangeRelCreation)p).Source == item.Entity || ((EntityChangeRelCreation)p).Destination == item.Entity)).ToList())
            {
                RelDeletionChange(new EntityChangeRelDeletion(rel.Entity as IOgmConnection));
            }
        }