예제 #1
0
 public void Attach_IDataObject_New()
 {
     using (IZetboxContext ctx = GetContext())
     {
         TestObjClass obj = new TestObjClassEfImpl(null);
         Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached));
         ctx.Internals().AttachAsNew(obj);
         Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Added));
     }
 }
예제 #2
0
        public void AttachedObjects()
        {
            using (IZetboxContext ctx = GetContext())
            {
                TestObjClass obj = new TestObjClassEfImpl(null);
                ctx.Attach(obj);
                ctx.Create <TestObjClass>();

                Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(2));
            }
        }
예제 #3
0
 public void Attach_IDataObject_Existing()
 {
     using (IZetboxContext ctx = GetContext())
     {
         TestObjClass obj = new TestObjClassEfImpl(null)
         {
             ID = 3, ClientObjectState = DataObjectState.Unmodified
         };
         Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached));
         ctx.Attach(obj);
         Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Unchanged));
     }
 }
예제 #4
0
        public void ContainsObject_Not()
        {
            using (IZetboxContext ctx = GetContext())
            {
                TestObjClass obj = new TestObjClassEfImpl(null)
                {
                    ID = 10
                };
                ctx.Create <TestObjClass>();
                Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(1));

                Assert.That(ctx.ContainsObject(ctx.GetInterfaceType(obj), obj.ID), Is.Null);
            }
        }