예제 #1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            InnerKey cidSuperID = obj as InnerKey;

            if (cidSuperID == null)
            {
                return(false);
            }

            if (_aKey != null ? !_aKey.Equals(cidSuperID._aKey) : cidSuperID._aKey != null)
            {
                return(false);
            }
            if (_bKey != null ? !_bKey.Equals(cidSuperID._bKey) : cidSuperID._bKey != null)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
		public void KeyManyToOne()
		{
			ISession s = OpenSession();
			Inner sup = new Inner();
			InnerKey sid = new InnerKey();
			sup.Dudu = "dudu";
			sid.AKey = "a";
			sid.BKey = "b";
			sup.Id = sid;
			Middle m = new Middle();
			MiddleKey mid = new MiddleKey();
			mid.One = "one";
			mid.Two = "two";
			mid.Sup = sup;
			m.Id = mid;
			m.Bla = "bla";
			Outer d = new Outer();
			OuterKey did = new OuterKey();
			did.Master = m;
			did.DetailId = "detail";
			d.Id = did;
			d.Bubu = "bubu";
			s.Save(sup);
			s.Save(m);
			s.Save(d);
			s.Flush();
			s.Close();

			s = OpenSession();
			d = (Outer) s.Load(typeof(Outer), did);
			Assert.AreEqual("dudu", d.Id.Master.Id.Sup.Dudu);
			s.Delete(d);
			s.Delete(d.Id.Master);
			s.Save(d.Id.Master);
			s.Save(d);
			s.Flush();
			s.Close();

			s = OpenSession();
			d = (Outer) s.CreateQuery("from Outer o where o.id.DetailId=?").SetString(0, d.Id.DetailId).List()[0];
			s.CreateQuery("from Outer o where o.Id.Master.Id.Sup.Dudu is not null").List();
			s.CreateQuery("from Outer o where o.Id.Master.Bla = ''").List();
			s.CreateQuery("from Outer o where o.Id.Master.Id.One = ''").List();
			s.Delete(d);
			s.Delete(d.Id.Master);
			s.Delete(d.Id.Master.Id.Sup);
			s.Flush();
			s.Close();
		}