private bool FilterParent(SelfReferencingComposition_OneToMany entity) { return (entity.ID == this.ParentID); }
private void DetachChildren(SelfReferencingComposition_OneToMany entity) { entity.Parent = null; }
public void Composition_EntityReferenceBug() { ConfigurableEntityContainer container = new ConfigurableEntityContainer(); container.CreateSet<SelfReferencingComposition_OneToMany>(EntitySetOperations.All); SelfReferencingComposition_OneToMany s1 = new SelfReferencingComposition_OneToMany() { ID = 1 }; SelfReferencingComposition_OneToMany s2 = new SelfReferencingComposition_OneToMany() { ID = 2, ParentID = 1 }; SelfReferencingComposition_OneToMany s3 = new SelfReferencingComposition_OneToMany() { ID = 3, ParentID = 1 }; SelfReferencingComposition_OneToMany s4 = new SelfReferencingComposition_OneToMany() { ID = 4, ParentID = 3 }; container.LoadEntities(new Entity[] { s1, s2, s3, s4 }); SelfReferencingComposition_OneToMany child = s1.Children.Single(p => p.ID == 2); child.Value += "x"; EntityChangeSet cs = container.GetChanges(); Assert.AreEqual(2, cs.ModifiedEntities.Count); List<ChangeSetEntry> entries = ChangeSetBuilder.Build(cs); Assert.AreEqual(4, entries.Count); }
private void AttachChildren(SelfReferencingComposition_OneToMany entity) { entity.Parent = this; }
[Ignore] // repro test - enable once bug is fixed public void CompositionSelfReference_UpdateChildBypassingParent() { ConfigurableEntityContainer container = new ConfigurableEntityContainer(); container.CreateSet<SelfReferencingComposition_OneToMany>(EntitySetOperations.All); SelfReferencingComposition_OneToMany s1 = new SelfReferencingComposition_OneToMany() { ID = 1 }; SelfReferencingComposition_OneToMany s2 = new SelfReferencingComposition_OneToMany() { ID = 2, ParentID = 1 }; container.LoadEntities(new Entity[] { s1, s2 }); // load the child w/o loading the parent SelfReferencingComposition_OneToMany child = container.GetEntitySet<SelfReferencingComposition_OneToMany>().Single(p => p.ID == 2); Assert.IsNull(((Entity)child).Parent); child.Value += "x"; // When this bug is fixed, we'd expect an exception during ChangeSetBuilder.Build EntityChangeSet cs = container.GetChanges(); List<ChangeSetEntry> entries = ChangeSetBuilder.Build(cs); }