예제 #1
0
        private Componentizable GetMaster(String name, String subName, String subName1)
        {
            Componentizable master = new Componentizable();

            if (name != null)
            {
                NHibernate.DomainModel.Component masterComp = new NHibernate.DomainModel.Component();
                masterComp.Name = name;
                if (subName != null || subName1 != null)
                {
                    SubComponent subComponent = new SubComponent();
                    subComponent.SubName    = subName;
                    subComponent.SubName1   = subName1;
                    masterComp.SubComponent = subComponent;
                }
                master.Component = masterComp;
            }
            return(master);
        }
예제 #2
0
        private void ComponentTest(string sql)
        {
            ISession session = OpenSession();

            Componentizable c = new Componentizable();

            c.NickName = "Flacky";
            NHibernate.DomainModel.Component component = new NHibernate.DomainModel.Component();
            component.Name = "flakky comp";
            SubComponent subComponent = new SubComponent();

            subComponent.SubName   = "subway";
            component.SubComponent = subComponent;

            c.Component = component;

            session.Save(c);

            session.Flush();

            session.Clear();

            IQuery q    = session.CreateSQLQuery(sql).AddEntity("comp", typeof(Componentizable));
            IList  list = q.List();

            Assert.AreEqual(list.Count, 1);

            Componentizable co = (Componentizable)list[0];

            Assert.AreEqual(c.NickName, co.NickName);
            Assert.AreEqual(c.Component.Name, co.Component.Name);
            Assert.AreEqual(c.Component.SubComponent.SubName, co.Component.SubComponent.SubName);

            session.Delete(co);
            session.Flush();
            session.Close();
        }
예제 #3
0
        private async Task ComponentTestAsync(string sql, CancellationToken cancellationToken = default(CancellationToken))
        {
            ISession session = OpenSession();

            Componentizable c = new Componentizable();

            c.NickName = "Flacky";
            NHibernate.DomainModel.Component component = new NHibernate.DomainModel.Component();
            component.Name = "flakky comp";
            SubComponent subComponent = new SubComponent();

            subComponent.SubName   = "subway";
            component.SubComponent = subComponent;

            c.Component = component;

            await(session.SaveAsync(c, cancellationToken));

            await(session.FlushAsync(cancellationToken));

            session.Clear();

            IQuery q    = session.CreateSQLQuery(sql).AddEntity("comp", typeof(Componentizable));
            IList  list = await(q.ListAsync(cancellationToken));

            Assert.AreEqual(list.Count, 1);

            Componentizable co = (Componentizable)list[0];

            Assert.AreEqual(c.NickName, co.NickName);
            Assert.AreEqual(c.Component.Name, co.Component.Name);
            Assert.AreEqual(c.Component.SubComponent.SubName, co.Component.SubComponent.SubName);

            await(session.DeleteAsync(co, cancellationToken));
            await(session.FlushAsync(cancellationToken));
            session.Close();
        }
		private Componentizable GetMaster(String name, String subName, String subName1)
		{
			Componentizable master = new Componentizable();
			if (name != null)
			{
				Component masterComp = new Component();
				masterComp.Name = name;
				if (subName != null || subName1 != null)
				{
					SubComponent subComponent = new SubComponent();
					subComponent.SubName = subName;
					subComponent.SubName1 = subName1;
					masterComp.SubComponent = subComponent;
				}
				master.Component = masterComp;
			}
			return master;
		}
		private void ComponentTest( string sql )
		{
			ISession session = OpenSession();
	    
			Componentizable c = new Componentizable();
			c.NickName = "Flacky";
			Component component = new Component();
			component.Name = "flakky comp";
			SubComponent subComponent = new SubComponent();
			subComponent.SubName = "subway";
			component.SubComponent = subComponent;
	    
			c.Component = component;
        
			session.Save(c);
        
			session.Flush();

			session.Clear();
        
			IQuery q = session.CreateSQLQuery(sql, "comp", typeof( Componentizable ));
			IList list = q.List();
	    
			Assert.AreEqual(list.Count,1);
	    
			Componentizable co = (Componentizable) list[0];
	    
			Assert.AreEqual(c.NickName, co.NickName);
			Assert.AreEqual(c.Component.Name, co.Component.Name);
			Assert.AreEqual(c.Component.SubComponent.SubName, co.Component.SubComponent.SubName);
	    
			session.Delete(co);
			session.Flush();
			session.Close();
		}