public override bool Equals(object obj) { if (this == obj) { return(true); } Outer rhs = obj as Outer; if (rhs == null) { return(false); } if (_id != null ? !_id.Equals(rhs.Id) : rhs.Id != null) { return(false); } return(true); }
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(); }