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();
			}
		}
예제 #2
0
		public virtual Membership AddMembership(Group group)
		{
			var membership = new Membership(this, group);
			memberships.Add(membership);
			return membership;
		}
예제 #3
0
		public Membership(User user, Group @group) : this(user, group, DateTime.Now) {}
예제 #4
0
		public Membership(User user, Group @group, DateTime activationDate)
		{
			User = user;
			Group = group;
			ActivationDate = activationDate;
		}