Пример #1
0
		public void Update()
		{
			ISession session1 = OpenSession();

			Parent parent1 = new Parent();
			Child child1 = new Child();
			parent1.AddChild(child1);

			long pId = (long) session1.Save(parent1);
			long cId = (long) session1.Save(child1);
			session1.Flush();
			session1.Close();

			ISession session2 = OpenSession();
			Parent parent = session2.Load(typeof(Parent), pId) as Parent;
			Child child = session2.Load(typeof(Child), cId) as Child;
			session2.Close();

			parent.AddChild(child);
			Child newChild = new Child();
			parent.AddChild(newChild);

			ISession session = OpenSession();
			session.Update(parent);
			session.Flush();
			session.Close();

			// Clean up
			using (ISession s = OpenSession())
			{
				s.Delete("from Parent");
				s.Flush();
			}
		}
Пример #2
0
		public void AddChild(Child c)
		{
			if (this.Children == null)
			{
				this.Children = new HashedSet();
			}
			this.Children.Add(c);
			c.Parent = this;
		}
Пример #3
0
		public void AddChild(Child c)
		{
			if (Children == null)
			{
				Children = new HashSet<Child>();
			}
			Children.Add(c);
			c.Parent = this;
		}