Пример #1
0
		public void Collection()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Multi multi1 = new Multi();
			multi1.ExtraProp = "extra1";
			Multi multi2 = new Multi();
			multi2.ExtraProp = "extra2";
			Po po = new Po();
			multi1.Po = po;
			multi2.Po = po;
			po.Set = new HashSet<Multi> {multi1, multi2};
			po.List = new List<SubMulti> {new SubMulti()};
			object id = s.Save(po);
			Assert.IsNotNull(id);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			po = (Po) s.Load(typeof(Po), id);
			Assert.AreEqual(2, po.Set.Count);
			Assert.AreEqual(1, po.List.Count);
			s.Delete(po);
			Assert.AreEqual(0, s.CreateQuery("from s in class Top").List().Count);
			t.Commit();
			s.Close();
		}
		public void Collection() 
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Multi multi1 = new Multi();
			multi1.ExtraProp = "extra1";
			Multi multi2 = new Multi();
			multi2.ExtraProp = "extra2";
			Po po = new Po();
			multi1.Po = po;
			multi2.Po = po;
			po.Set = new Iesi.Collections.HashedSet();
			po.Set.Add( multi1 );
			po.Set.Add( multi2 );
			po.List = new ArrayList();
			po.List.Add( new SubMulti() );
			object id = s.Save(po);
			Assert.IsNotNull(id);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			po = (Po)s.Load( typeof(Po), id );
			Assert.AreEqual( 2, po.Set.Count );
			Assert.AreEqual( 1, po.List.Count );
			s.Delete(po);
			Assert.AreEqual( 0, s.Find("from s in class Top").Count );
			t.Commit();
			s.Close();

		}