예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
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);
        }