Exemplo n.º 1
0
		protected override void OnSetUp()
		{
			using (ISession session = OpenSession())
			using (ITransaction transaction = session.BeginTransaction())
			{
				var child1 = new Child { Name = "Child 1" };
				var child2 = new Child { Name = "Child 2" };
				var child3 = new Child { Name = "Child 3" };

				var parent1 = new Parent { Name = "Parent 1", ParentCode = 10 };
				var parent2 = new Parent { Name = "Parent 2", ParentCode = 20 };

				session.Save(parent1);
				session.Save(parent2);

				parent1.AddChild(child1);
				parent1.AddChild(child2);
				parent2.AddChild(child3);

				session.Save(child1);
				session.Save(child2);
				session.Save(child3);

				transaction.Commit();
			}
		}
Exemplo n.º 2
0
		public virtual void AddChild(Child child)
		{
			Children.Add(child);
			child.Parent = this;
		}