예제 #1
0
		public MaterialUnit(MaterialUnitable material, string serialNumber) : this()
		{
			_material = material;
			_serialNumber = serialNumber;
		}
		public void PropertySubClassDiscriminator()
		{
			using (ISession s = OpenSession())
			{
				MaterialUnitable bo1 = new MaterialUnitable();
				bo1.Description = "Seal";
				MaterialUnitable bo2 = new MaterialUnitable();
				bo2.Description = "Meter";
				MaterialUnitable dv = new DeviceDef();
				dv.Description = "Printer";
				s.Save(bo1);
				s.Save(bo2);
				s.Save(dv);
				s.Flush();

				MaterialUnit mu = new MaterialUnit(bo1, "S1");
				s.Save(mu);
				mu = new MaterialUnit(bo1, "S2");
				s.Save(mu);
				mu = new MaterialUnit(bo2, "M1");
				s.Save(mu);
				mu = new MaterialUnit(dv, "D1");
				s.Save(mu);
				s.Flush();
			}

			using (ISession session = OpenSession())
			{
				IList l = session.CreateCriteria(typeof(MaterialUnit), "mu")
					.CreateAlias("mu.Material", "ma")
					.Add(Property.ForName("ma.class").Eq(typeof(MaterialUnitable)))
					.List();
				Assert.AreEqual(3, l.Count);
			}

			using (ISession s = OpenSession())
			{
				s.Delete("from MaterialUnit");
				s.Delete("from MaterialResource");
				s.Flush();
			}
		}
예제 #3
0
 public MaterialUnit(MaterialUnitable material, string serialNumber) : this()
 {
     _material     = material;
     _serialNumber = serialNumber;
 }