public void DetachWithNonIncludedExistingEntityTest() { EntityGraphTestsDomainContext ctx = new EntityGraphTestsDomainContext(); LoadOperation <B> loadOp = ctx.Load(ctx.GetBSetQuery()); EnqueueConditional(() => loadOp.IsComplete); EnqueueCallback( () => { EntityGraph gr = a.EntityGraph(EntityGraphs.CircularGraphFull); B existingB = ctx.Bs.Single(); ctx.As.Add(a); a.BNotInGraph = existingB; Assert.IsTrue(a.EntityState == EntityState.New); Assert.IsTrue(a.BNotInGraph.EntityState == EntityState.Unmodified); Assert.IsTrue(a.BNotInGraphId == existingB.Id); gr.DetachEntityGraph(ctx.As); Assert.IsTrue(a.EntityState == EntityState.Detached); Assert.IsTrue(a.BNotInGraph.EntityState == EntityState.Unmodified); Assert.IsTrue(a.BNotInGraphId == existingB.Id); }); EnqueueTestComplete(); }
public void DetachTest() { EntityGraph gr = a.EntityGraph(EntityGraphs.CircularGraphFull); EntityGraphTestsDomainContext ctx = new EntityGraphTestsDomainContext(); a.BSet.Add(new B()); ctx.As.Add(a); gr.DetachEntityGraph(ctx.As); Assert.IsTrue(ctx.EntityContainer.GetChanges().AddedEntities.Count() == 0); }
public void DetachWithNonIncludedNewEntityTest() { EntityGraphTestsDomainContext ctx = new EntityGraphTestsDomainContext(); EntityGraph gr = a.EntityGraph(EntityGraphs.CircularGraphFull); ctx.As.Add(a); var newB = new B(); a.BNotInGraph = newB; Assert.IsTrue(a.EntityState == EntityState.New); Assert.IsTrue(a.BNotInGraph.EntityState == EntityState.New); Assert.IsTrue(a.BNotInGraphId == newB.Id); gr.DetachEntityGraph(ctx.As); Assert.IsTrue(a.EntityState == EntityState.Detached); Assert.IsTrue(a.BNotInGraph.EntityState == EntityState.New); Assert.IsTrue(a.BNotInGraphId == newB.Id); }