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

            Several rhs = obj as Several;

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

            return(rhs.Id.Equals(this.Id) && rhs.String.Equals(this.String));
        }
		public void NonLazyBidirectional()
		{
			Single sin = new Single();
			sin.Id = "asfdfds";
			sin.String = "adsa asdfasd";
			Several sev = new Several();
			sev.Id = "asdfasdfasd";
			sev.String = "asd ddd";
			sin.Several.Add(sev);
			sev.Single = sin;

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.Save(sin);
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				sin = (Single) s.Load(typeof(Single), sin);
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				sev = (Several) s.Load(typeof(Several), sev);
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.CreateQuery("from s in class Several").List();
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.CreateQuery("from s in class Single").List();
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.Delete("from Single");
				t.Commit();
			}
		}