Example #1
0
        public async System.Threading.Tasks.Task WithTablePerConcreteInheritance_BiggerAsync()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    for (int i = 0; i < 12; i++)
                    {
                        var person = new PersonTpc();
                        person.AddAddress(new AddressTpc());
                        await(session.SaveAsync(person));

                        // Derived Object with dependent object (address)
                        var specialPerson = new SpecialPersonTpc();
                        specialPerson.AddAddress(new AddressTpc());
                        await(session.SaveAsync(specialPerson));
                    }

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

            // 12 Person inserts (2 batches), 12 SpecialPerson inserts (2 batches), 24 Address inserts
            // (may get intervened between Person and SpecialPerson, case not currently optimized: 3 to 4 batches)
            Assert.That(StatsBatcher.BatchSizes.Count, Is.InRange(7, 8), "Unexpected batches count");
            Assert.AreEqual(48, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }
Example #2
0
        public void WithTablePerConcreteInheritance()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    var person = new PersonTpc();
                    person.AddAddress(new AddressTpc());
                    session.Save(person);

                    // Derived Object with dependent object (address)
                    var specialPerson = new SpecialPersonTpc();
                    specialPerson.AddAddress(new AddressTpc());
                    session.Save(specialPerson);

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

            // 1 Person insert, 1 SpecialPerson insert, 2 Address inserts
            // (may get intervened between Person and SpecialPerson, case not currently optimized: 1 to 2 batches for adresses)
            Assert.That(StatsBatcher.BatchSizes.Count, Is.InRange(3, 4), "Unexpected batches count");
            Assert.AreEqual(4, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }