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