public async System.Threading.Tasks.Task WithSingleTableInheritance_BiggerAsync()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    for (int i = 0; i < 12; i++)
                    {
                        var person = new PersonSti();
                        person.AddAddress(new AddressSti());
                        await(session.SaveAsync(person));

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

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

            // 12 Person inserts (2 batches), 12 SpecialPerson inserts (into Person but with different columns, 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");
        }
Exemple #2
0
        public void WithSingleTableInheritance()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    var person = new PersonSti();
                    person.AddAddress(new AddressSti());
                    session.Save(person);

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

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

            // 1 Person insert, 1 SpecialPerson insert (into Person but with different columns), 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");
        }