Esempio n. 1
0
        public async System.Threading.Tasks.Task WithJoinedTableInheritance_BiggerAsync()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    for (int i = 0; i < 12; i++)
                    {
                        var person = new PersonJI();
                        person.AddAddress(new AddressJI());
                        await(session.SaveAsync(person));

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

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

            // 12 Person inserts (2 batches), 12 SpecialPerson inserts (SpecialPerson inserts fragment batches
            // (additional inserts for joined table currently not taken into account by inserts sorting), but first
            // may get collapsed with Person: 11 to 12 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(16, 18), "Unexpected batches count");
            Assert.AreEqual(48, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }
Esempio n. 2
0
        public async System.Threading.Tasks.Task WithJoinedTableInheritanceAsync()
        {
            using (ISession session = OpenSession())
                using (var trx = session.BeginTransaction())
                {
                    var person = new PersonJI();
                    person.AddAddress(new AddressJI());
                    await(session.SaveAsync(person));

                    // Derived Object with dependent object (address)
                    var specialPerson = new SpecialPersonJI();
                    specialPerson.AddAddress(new AddressJI());
                    await(session.SaveAsync(specialPerson));

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

            // 1 Person inserts, 1 SpecialPerson insert (may get collapsed with Person: 0 to 1 batches),
            // 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(2, 4), "Unexpected batches count");
            Assert.AreEqual(4, StatsBatcher.BatchSizes.Sum(), "Unexpected batched queries count");
        }