Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
 public void Null()
 {
     var a = new Form();
     ActiveRecordMediator.Create(a);
     ActiveRecordMediator<Form>.FindAll(EqOrNull("Name", null));
 }
Exemplo n.º 3
0
 public void IsTransient()
 {
     var aform = new Form();
     var pk = ActiveRecordModel.GetModel(typeof(Form)).PrimaryKey;
     var unsavedValue = pk.PrimaryKeyAtt.UnsavedValue;
     var convertedUnsavedValue = Convert.ChangeType(unsavedValue, pk.Property.PropertyType);
     var pkValue = pk.Property.GetValue(aform, null);
     var transient = Equals(convertedUnsavedValue, pkValue);
 }
Exemplo n.º 4
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));
 }
Exemplo n.º 5
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));
        }