Ejemplo n.º 1
0
        public void WithUnidiOneToOne()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    var worker   = new PersonUO2O();
                    var homestay = new PersonUO2O();

                    var home   = new AddressUO2O();
                    var office = new AddressUO2O();

                    home.SetPerson(homestay);
                    office.SetPerson(worker);

                    session.Save(home);
                    session.Save(office);

                    Assert.DoesNotThrow(() => { trx.Commit(); });
                }

            // 2 Person inserts, 2 Address inserts
            Assert.AreEqual(2, StatsBatcher.BatchSizes.Count, "Unexpected batches count");
            Assert.AreEqual(4, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }
Ejemplo n.º 2
0
        public async System.Threading.Tasks.Task WithUnidiOneToOneAsync()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    var worker   = new PersonUO2O();
                    var homestay = new PersonUO2O();

                    var home   = new AddressUO2O();
                    var office = new AddressUO2O();

                    home.SetPerson(homestay);
                    office.SetPerson(worker);

                    await(session.SaveAsync(home));
                    await(session.SaveAsync(office));

                    Assert.DoesNotThrowAsync(() => { return(trx.CommitAsync()); });
                }

            // 2 Person inserts, 2 Address inserts
            Assert.AreEqual(2, StatsBatcher.BatchSizes.Count, "Unexpected batches count");
            Assert.AreEqual(4, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }
Ejemplo n.º 3
0
 public virtual void SetPerson(PersonUO2O person)
 {
     Person = person;
 }