Пример #1
0
		public void AddEmployee(Employee e)
		{
			if (e != null && !_employees.Contains(e))
			{
				e.Department = this;
				_employees.Add(e);
			}
		}
Пример #2
0
		protected override void OnSetUp()
		{
			base.OnSetUp();
			using (ISession session = OpenSession())
			{
				var e1 = new Employee(1, "Employee1", new DateTime(1995, 1, 1));
				var e2 = new Employee(2, "Employee2", new DateTime(2007, 8, 1));
				var e3 = new Employee(3, "Employee3", new DateTime(2009, 5, 1));

				var d1 = new Department(1, "Department S");

				d1.AddEmployee(e1);
				d1.AddEmployee(e2);

				session.SaveOrUpdate(d1);
				session.SaveOrUpdate(e1);
				session.SaveOrUpdate(e2);
				session.SaveOrUpdate(e3);

				session.Flush();
			}
		}
Пример #3
0
		protected override void OnSetUp()
		{
			using (var session = OpenSession())
			using (var transaction = session.BeginTransaction())
			{
				var e1 = new Employee(1, "Employee1", new DateTime(1995, 1, 1));
				var e2 = new Employee(2, "Employee2", new DateTime(2007, 8, 1));
				var e3 = new Employee(3, "Employee3", new DateTime(2009, 5, 1));

				var d1 = new Department(1, "Department S");

				d1.AddEmployee(e1);
				d1.AddEmployee(e2);

				session.SaveOrUpdate(d1);
				session.SaveOrUpdate(e1);
				session.SaveOrUpdate(e2);
				session.SaveOrUpdate(e3);

				transaction.Commit();
			}
		}