コード例 #1
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();
			}
		}
コード例 #2
0
ファイル: User.cs プロジェクト: Ruhollah/nhibernate-core
		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;
		}