Example #1
0
 public void LazyBelongsTo()
 {
     var form = new Form();
     var partA = new FormPartA();
     ActiveRecordMediator.Create(form);
     ActiveRecordMediator.Create(partA);
     form.PartA = partA;
     ActiveRecordMediator.Update(form);
     partA.Parent = form;
     ActiveRecordMediator.Update(partA);
     var form1 = ActiveRecordMediator<Form>.FindFirst();
     Assert.IsFalse(NHibernateUtil.IsInitialized(form1.PartA));
 }
Example #2
0
 public void StatelessSession()
 {
     var a = new FormPartA();
     ActiveRecordMediator<FormPartA>.Create(a);
     using (var session = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof (object)).OpenStatelessSession()) {
         var entityA = new Form();
         entityA.PartA = session.Get<FormPartA>(a.Id);
         session.Insert(entityA);
     }
 }
Example #3
0
        public void IsLazy()
        {
            var form = new Form();
            var partA = new FormPartA();
            var partB = new FormPartB();
            ActiveRecordMediator.Create(form);
            ActiveRecordMediator.Create(partA);
            ActiveRecordMediator.Create(partB);
            form.PartA = partA;
            form.PartB = partB;
            ActiveRecordMediator.Update(form);
            partA.Parent = form;
            ActiveRecordMediator.Update(partA);
            partB.Parent = form;
            ActiveRecordMediator.Update(partB);

            LogManager.GetLogger("test").Debug("All objects saved");

            var form1 = ActiveRecordMediator<Form>.FindFirst();
            Assert.IsTrue(NHibernateUtil.IsInitialized(form1.PartA));
            Assert.IsTrue(NHibernateUtil.IsInitialized(form1.PartB));

            var partA1 = ActiveRecordMediator<FormPartA>.FindFirst();
            Assert.IsFalse(NHibernateUtil.IsInitialized(partA1.Parent));

            var partB1 = ActiveRecordMediator<FormPartB>.FindFirst();
            Assert.IsFalse(NHibernateUtil.IsInitialized(partB1.Parent));
        }