Esempio n. 1
0
        public async System.Threading.Tasks.Task BatchOrderingAsync()
        {
            using (ISession s = OpenSession())
                using (s.BeginTransaction())
                {
                    for (int i = 0; i < instancesPerEach; i++)
                    {
                        var user = new User {
                            UserName = "******" + i
                        };
                        var group = new Group {
                            Name = "group-" + i
                        };
                        await(s.SaveAsync(user));
                        await(s.SaveAsync(group));
                        user.AddMembership(group);
                    }
                    StatsBatcher.Reset();
                    await(s.Transaction.CommitAsync());
                }

            int expectedBatchesPerEntity = (instancesPerEach / batchSize) + ((instancesPerEach % batchSize) == 0 ? 0 : 1);

            Assert.That(StatsBatcher.BatchSizes.Count, Is.EqualTo(expectedBatchesPerEntity * typesOfEntities));
        }
		public void BatchOrdering()
		{
			using (ISession s = OpenSession())
			using (s.BeginTransaction())
			{
				for (int i = 0; i < instancesPerEach; i++)
				{
					var user = new User {UserName = "******" + i};
					var group = new Group {Name = "group-" + i};
					s.Save(user);
					s.Save(group);
					user.AddMembership(group);
				}
				StatsBatcher.Reset();
				s.Transaction.Commit();
			}

			int expectedBatchesPerEntity = (instancesPerEach / batchSize) + ((instancesPerEach % batchSize) == 0 ?  0 : 1);
			StatsBatcher.BatchSizes.Count.Should().Be(expectedBatchesPerEntity * typesOfEntities);

			using (ISession s = OpenSession())
			{
				s.BeginTransaction();
				IList users = s.CreateQuery("from User u left join fetch u.Memberships m left join fetch m.Group").List();
				foreach (object user in users)
				{
					s.Delete(user);
				}
				s.Transaction.Commit();
			}
		}
Esempio n. 3
0
        public void BatchOrdering()
        {
            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    for (int i = 0; i < instancesPerEach; i++)
                    {
                        var user = new User {
                            UserName = "******" + i
                        };
                        var group = new Group {
                            Name = "group-" + i
                        };
                        s.Save(user);
                        s.Save(group);
                        user.AddMembership(group);
                    }
                    StatsBatcher.Reset();
                    t.Commit();
                }

            int expectedBatchesPerEntity = (instancesPerEach / batchSize) + ((instancesPerEach % batchSize) == 0 ? 0 : 1);

            Assert.That(StatsBatcher.BatchSizes.Count, Is.EqualTo(expectedBatchesPerEntity * typesOfEntities));
        }
Esempio n. 4
0
        public void BatchOrdering()
        {
            using (ISession s = OpenSession())
                using (s.BeginTransaction())
                {
                    for (int i = 0; i < instancesPerEach; i++)
                    {
                        var user = new User {
                            UserName = "******" + i
                        };
                        var group = new Group {
                            Name = "group-" + i
                        };
                        s.Save(user);
                        s.Save(group);
                        user.AddMembership(group);
                    }
                    StatsBatcher.Reset();
                    s.Transaction.Commit();
                }

            int expectedBatchesPerEntity = (instancesPerEach / batchSize) + ((instancesPerEach % batchSize) == 0 ?  0 : 1);

            StatsBatcher.BatchSizes.Count.Should().Be(expectedBatchesPerEntity * typesOfEntities);

            using (ISession s = OpenSession())
            {
                s.BeginTransaction();
                IList users = s.CreateQuery("from User u left join fetch u.Memberships m left join fetch m.Group").List();
                foreach (object user in users)
                {
                    s.Delete(user);
                }
                s.Transaction.Commit();
            }
        }