• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DomainModel.Category类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NHibernate.DomainModel.Category的典型用法代码示例。如果您正苦于以下问题:C# Category类的具体用法?C# Category怎么用?C# Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Category类属于NHibernate.DomainModel命名空间,在下文中一共展示了Category类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FindBySQLStar

		public void FindBySQLStar()
		{
			ISession session = OpenSession();

			Category s = new Category();
			s.Name = nextLong.ToString();
			nextLong++;
			session.Save( s );

			Simple simple = new Simple();
			simple.Init();
			session.Save( simple, nextLong++ );

			A a = new A();
			session.Save( a );

			//B b = new B();
			//session.Save( b );

			session.CreateSQLQuery( "select {category.*} from Category {category}", "category", typeof( Category ) ).List();
			session.CreateSQLQuery( "select {simple.*} from Simple {simple}", "simple", typeof( Simple ) ).List();
			session.CreateSQLQuery( "select {a.*} from A {a}", "a", typeof( A ) ).List();

			session.Delete( s );
			session.Delete( simple );
			session.Delete( a );
			//session.Delete( b );
			session.Flush();
			session.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:30,代码来源:SQLLoaderTest.cs


示例2: CachedCollectionRefresh

        public void CachedCollectionRefresh()
        {
            ISession s = OpenSession();
            Category c = new Category();
            IList list = new ArrayList();
            c.Subcategories = list;
            list.Add(new Category());
            c.Name = "root";
            object id = s.Save(c);
            s.Flush();
            s.Close();

            s = OpenSession();
            c = (Category) s.Load(typeof(Category), id);
            NHibernateUtil.Initialize(c.Subcategories);

            ISession ss = OpenSession();
            Category c2 = (Category) ss.Load(typeof(Category), id);
            ss.Delete(c2.Subcategories[0]);
            c2.Subcategories.Clear();
            ss.Flush();
            ss.Close();

            s.Refresh(c);
            Assert.AreEqual(0, c.Subcategories.Count);

            ss = OpenSession();
            c2 = (Category) ss.Load(typeof(Category), id);
            c2.Subcategories.Add(new Category());
            c2.Subcategories.Add(new Category());
            ss.Flush();
            ss.Close();

            s.Refresh(c);
            Assert.AreEqual(2, c.Subcategories.Count);

            s.Flush();
            s.Close();

            s = OpenSession();
            c = (Category) s.Load(typeof(Category), id);
            Assert.AreEqual(2, c.Subcategories.Count);
            s.Delete(c);
            s.Flush();
            s.Close();
        }
开发者ID:aistrate,项目名称:TypingPracticeTexts,代码行数:46,代码来源:MasterDetailTest.cs


示例3: CopyCascade

		public void CopyCascade()
		{
			ISession s = OpenSession();
			Category child = new Category();
			child.Name = "child";
			s.Save(child);
			s.Flush();
			s.Close();

			s = OpenSession();
			Category parent = new Category();
			parent.Name = "parent";
			parent.Subcategories.Add(child);
			child.Name = "child2";

			// Save parent and cascade update detached child
			Category persistentParent = s.Merge(parent);
			Assert.IsTrue(persistentParent.Subcategories.Count == 1);
			Assert.AreEqual(((Category) persistentParent.Subcategories[0]).Name, "child2");
			s.Flush();
			s.Close();

			s = OpenSession();
			s.Delete(persistentParent);
			s.Flush();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:27,代码来源:MasterDetailTest.cs


示例4: PolymorphicCriteria

		public void PolymorphicCriteria()
		{
			ISession s = OpenSession();
			ITransaction txn = s.BeginTransaction();
			Category f = new Category();
			Single b = new Single();
			b.Id = "asdfa";
			b.String = "asdfasdf";
			s.Save(f);
			s.Save(b);
			IList list = s.CreateCriteria(typeof(object)).List();
			Assert.AreEqual(2, list.Count);
			Assert.IsTrue(list.Contains(f));
			Assert.IsTrue(list.Contains(b));
			s.Delete(f);
			s.Delete(b);
			txn.Commit();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:19,代码来源:MasterDetailTest.cs


示例5: QueuedBagAdds

		public void QueuedBagAdds()
		{
			ISession s = OpenSession();
			Assignable a = new Assignable();
			a.Id = "foo";
			a.Categories = new ArrayList();
			Category c = new Category();
			c.Assignable = a;
			a.Categories.Add(c);
			s.Save(a);
			s.Flush();
			s.Close();

			sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories");

			s = OpenSession();
			a = (Assignable) s.Get(typeof(Assignable), "foo");
			c = new Category();
			c.Assignable = a;
			a.Categories.Add(c);
			Assert.IsFalse(NHibernateUtil.IsInitialized(a.Categories));
			Assert.AreEqual(2, a.Categories.Count);
			s.Flush();
			s.Close();

			sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories");

			s = OpenSession();
			a = (Assignable) s.Get(typeof(Assignable), "foo");
			c = new Category();
			c.Assignable = a;
			a.Categories.Add(c);
			Assert.IsFalse(NHibernateUtil.IsInitialized(a.Categories));
			s.Flush();
			Assert.IsFalse(NHibernateUtil.IsInitialized(a.Categories));
			Assert.AreEqual(3, a.Categories.Count);
			s.Close();

			sessions.EvictCollection("NHibernate.DomainModel.Assignable.Categories");

			s = OpenSession();
			a = (Assignable) s.Get(typeof(Assignable), "foo");
			Assert.AreEqual(3, a.Categories.Count);
			s.Delete(a);
			s.Flush();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:47,代码来源:MasterDetailTest.cs


示例6: CollectionRefresh

		public void CollectionRefresh()
		{
			ISession s = OpenSession();
			Category c = new Category();
			IList list = new ArrayList();
			c.Subcategories = list;
			list.Add(new Category());
			c.Name = "root";
			object id = s.Save(c);
			s.Flush();
			s.Close();

			s = OpenSession();
			c = (Category) s.Load(typeof(Category), id);
			s.Refresh(c);
			s.Flush();

			Assert.AreEqual(1, c.Subcategories.Count);
			s.Flush();
			s.Close();

			s = OpenSession();
			c = (Category) s.Load(typeof(Category), id);
			Assert.AreEqual(1, c.Subcategories.Count);

			// modify the collection in another session
			ISession s2 = OpenSession();
			Category c2 = (Category) s2.Load(typeof(Category), id);
			c2.Subcategories.Add(new Category());
			s2.Flush();
			s2.Close();

			// now lets refresh the collection and see if it picks up 
			// the new objects
			s.Refresh(c);
			Assert.AreEqual(2, c.Subcategories.Count, "should have gotten the addition from s2");

			s.Delete(c);
			s.Flush();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:41,代码来源:MasterDetailTest.cs


示例7: PolymorphicCriteria

		public void PolymorphicCriteria()
		{
			ISession s = OpenSession();
			Category f = new Category();
			DomainModel.Single b = new DomainModel.Single();
			b.Id = "asdfa";
			b.String = "asdfasdf";
			s.Save( f );
			s.Save( b );
			IList list = s.CreateCriteria( typeof( object )).List();
			Assert.AreEqual( 2, list.Count );
			Assert.IsTrue( list.Contains( f ) );
			Assert.IsTrue( list.Contains( b ) );
			s.Delete( f );
			s.Delete( b );
			s.Flush();
			s.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:18,代码来源:MasterDetailTest.cs


示例8: Categories

		public void Categories()
		{
			Category c = new Category();
			c.Name = Category.RootCategory;
			Category c1 = new Category();
			Category c2 = new Category();
			Category c3 = new Category();
			c.Subcategories.Add(c1);
			c.Subcategories.Add(c2);
			c2.Subcategories.Add(null);
			c2.Subcategories.Add(c3);

			using (ISession s = OpenSession())
			{
				s.Save(c);
				s.Flush();
			}

			using (ISession s = OpenSession())
			{
				c = (Category) s.Load(typeof(Category), c.Id);
				Assert.IsNotNull(c.Subcategories[0]);
				Assert.IsNotNull(c.Subcategories[1]);
				IList list = ((Category) c.Subcategories[1]).Subcategories;
				Assert.IsNull(list[0]);
				Assert.IsNotNull(list[1]);

				IEnumerator enumer =
					s.CreateQuery("from c in class Category where c.Name = NHibernate.DomainModel.Category.RootCategory").Enumerable().
						GetEnumerator();
				Assert.IsTrue(enumer.MoveNext());
			}

			using (ISession s = OpenSession())
			{
				s.Delete("from Category");
				s.Flush();
			}
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:39,代码来源:MasterDetailTest.cs


示例9: FindBySQLParameters

		public void FindBySQLParameters()
		{
			ISession s = OpenSession();
			Category c = new Category();
			c.Name = "Good";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			IList l = new ArrayList();
			l.Add(c);
			assn.Categories = l;
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();
			c = new Category();
			c.Name = "Best";
			assn = new Assignable();
			assn.Id = "i.d.2";
			l = new ArrayList();
			l.Add(c);
			assn.Categories = l;
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();
			c = new Category();
			c.Name = "Better";
			assn = new Assignable();
			assn.Id = "i.d.7";
			l = new ArrayList();
			l.Add(c);
			assn.Categories = l;
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();

			assn = new Assignable();
			assn.Id = "i.d.3";
			s.Save(assn);
			s.Flush();
			s.Close();

			s = OpenSession();
			IQuery basicParam = s.CreateSQLQuery("select {category.*} from Category {category} where {category}.Name = 'Best'", "category", typeof( Category ));
			IList list = basicParam.List();
			Assert.AreEqual(1, list.Count);

			IQuery unnamedParam = s.CreateSQLQuery("select {category.*} from Category {category} where {category}.Name = ? or {category}.Name = ?", "category", typeof( Category ));
			unnamedParam.SetString(0, "Good");
			unnamedParam.SetString(1, "Best");
			list = unnamedParam.List();
			Assert.AreEqual(2, list.Count);
		
			IQuery namedParam = s.CreateSQLQuery("select {category.*} from Category {category} where ({category}.Name=:firstCat or {category}.Name=:secondCat)", "category", typeof( Category ));
			namedParam.SetString("firstCat", "Better");
			namedParam.SetString("secondCat", "Best");
			list = namedParam.List();
			Assert.AreEqual(2, list.Count);
		
			s.Delete("from Assignable");
			s.Delete("from Category");
			s.Flush();
			s.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:62,代码来源:SQLLoaderTest.cs


示例10: FindBySQLMultipleObject

		public void FindBySQLMultipleObject()
		{
			ISession s = OpenSession();

			Category c = new Category();
			c.Name = "NAME";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			IList l = new ArrayList();
			l.Add( c );
			assn.Categories = l;
			c.Assignable = assn;
			s.Save( assn );
			s.Flush();

			c = new Category();
			c.Name = "NAME2";
			assn = new Assignable();
			assn.Id = "i.d.2";
			l = new ArrayList();
			l.Add( c );
			assn.Categories = l;
			c.Assignable = assn;
			s.Save( assn );
			s.Flush();

			assn = new Assignable();
			assn.Id = "i.d.3";
			s.Save( assn );
			s.Flush();
			s.Close();

			s = OpenSession();

			if ( !(dialect is Dialect.MySQLDialect) )
			{
				IList list = s.CreateSQLQuery( "select {category.*}, {assignable.*} from Category {category}, \"assign able\" {assignable}", new string[] { "category", "assignable" }, new System.Type[] { typeof( Category ), typeof( Assignable ) } ).List();
				Assert.AreEqual( 6, list.Count, "Count differs" ); // cross-product of 2 categories x 3 assignables;
				Assert.IsTrue( list[0] is object[] );
			}

			s.Delete( "from Assignable" );
			s.Delete( "from Category" );
			s.Flush();
			s.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:46,代码来源:SQLLoaderTest.cs


示例11: FindBySQLAssociatedObject

		public void FindBySQLAssociatedObject()
		{
			ISession s = OpenSession();

			Category c = new Category();
			c.Name = "NAME";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			IList l = new ArrayList();
			l.Add( c );
			assn.Categories = l;
			c.Assignable = assn;
			s.Save( assn );
			s.Flush();
			s.Close();

			s = OpenSession();
			IList list = s.CreateSQLQuery( "select {category.*} from Category {category}", "category", typeof( Category ) ).List();
			Assert.AreEqual( 1, list.Count, "Count differs" );

			s.Delete( "from Assignable" );
			s.Delete( "from Category" );
			s.Flush();
			s.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:25,代码来源:SQLLoaderTest.cs


示例12: FindBySQLProperties

		public void FindBySQLProperties()
		{
			ISession session = OpenSession();

			Category s = new Category();
			s.Name = nextLong.ToString();
			nextLong++;
			session.Save( s );

			s = new Category();
			s.Name = "WannaBeFound";
			session.Flush();

			IQuery query = session.CreateSQLQuery( "select {category.*} from Category {category} where {category}.Name = :Name", "category", typeof( Category ) );
			query.SetProperties( s );

			query.List();

			session.Delete( "from Category" );
			session.Flush();
			session.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:22,代码来源:SQLLoaderTest.cs


示例13: FindBySQLMultipleObject

		public void FindBySQLMultipleObject()
		{
			ISession s = OpenSession();

			Category c = new Category();
			c.Name = "NAME";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			assn.Categories = new List<Category> {c};
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();

			c = new Category();
			c.Name = "NAME2";
			assn = new Assignable();
			assn.Id = "i.d.2";
			assn.Categories = new List<Category> { c };
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();

			assn = new Assignable();
			assn.Id = "i.d.3";
			s.Save(assn);
			s.Flush();
			s.Close();

			s = OpenSession();

			if (!(Dialect is MySQLDialect))
			{
				IList list =
					s.CreateSQLQuery("select {category.*}, {assignable.*} from Category {category}, \"assign able\" {assignable}")
					.AddEntity("category",   typeof(Category))
					.AddEntity("assignable", typeof(Assignable))
					.List();
				Assert.AreEqual(6, list.Count, "Count differs"); // cross-product of 2 categories x 3 assignables;
				Assert.IsTrue(list[0] is object[]);
			}

			s.Delete("from Assignable");
			s.Delete("from Category");
			s.Flush();
			s.Close();
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:46,代码来源:SQLLoaderTest.cs


示例14: CollectionReplace2

		public void CollectionReplace2()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Category c = new Category();
			IList<Category> list = new List<Category>();
			c.Subcategories = list;
			list.Add(new Category());
			Category c2 = new Category();
			s.Save(c2);
			s.Save(c);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Category) s.Load(typeof(Category), c.Id, LockMode.Upgrade);
			IList<Category> list2 = c.Subcategories;
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c2 = (Category) s.Load(typeof(Category), c2.Id, LockMode.Upgrade);
			c2.Subcategories = list2;
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c2 = (Category) s.Load(typeof(Category), c2.Id, LockMode.Upgrade);
			Assert.AreEqual(1, c2.Subcategories.Count);
			s.Delete(c2);
			s.Delete(s.Load(typeof(Category), c.Id));
			t.Commit();
			s.Close();
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:37,代码来源:MasterDetailTest.cs


示例15: Copy

		public void Copy()
		{
			Category catWA = new Category();
			catWA.Name = "HSQL workaround";
			Category cat = new Category();
			cat.Name = "foo";
			Category subCatBar = new Category();
			subCatBar.Name = "bar";
			Category subCatBaz = new Category();
			subCatBaz.Name = "baz";
			cat.Subcategories.Add( subCatBar );
			cat.Subcategories.Add( subCatBaz );

			using( ISession s = OpenSession() )
			{
				s.Save( catWA );
				s.Save( cat );
				s.Flush();
			}

			cat.Name = "new foo";
			subCatBar.Name = "new bar";
			cat.Subcategories.Remove( subCatBaz );
			Category newCat = new Category();
			newCat.Name = "new";
			cat.Subcategories.Add( newCat );
			Category newSubCat = new Category();
			newSubCat.Name = "new sub";
			newCat.Subcategories.Add( newSubCat );

			using( ISession s = OpenSession() )
			{
				s.SaveOrUpdateCopy( cat );
				s.Flush();
			}

			using( ISession s = OpenSession() )
			{
				cat = (Category) s.CreateQuery( "from Category cat where cat.Name='new foo'").UniqueResult();
				newSubCat = (Category) s.CreateQuery( "from Category cat where cat.Name='new sub'").UniqueResult();
				newSubCat.Subcategories.Add( cat );
				subCatBaz = (Category) s.SaveOrUpdateCopy( newSubCat, subCatBaz.Id );
				Assert.IsTrue( subCatBaz.Name.Equals( "new sub" ) );
				Assert.IsTrue( subCatBaz.Subcategories.Count == 1 && subCatBaz.Subcategories[0] == cat );
				newSubCat.Subcategories.Remove( cat );
				s.Delete( cat );
				s.Delete( subCatBaz );
				s.Delete( catWA );
				s.Flush();
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:51,代码来源:MasterDetailTest.cs


示例16: MixNativeAssigned

		public void MixNativeAssigned()
		{
			// if HSQLDialect then skip test
			ISession s = OpenSession();
			Category c = new Category();
			c.Name = "NAME";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			IList l = new ArrayList();
			l.Add(c);
			assn.Categories = l;
			c.Assignable = assn;
			s.Save(assn);
			s.Flush();
			s.Close();

			s = OpenSession();
			s.Delete(assn);
			s.Flush();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:21,代码来源:MasterDetailTest.cs


示例17: CollectionReplace

		public void CollectionReplace()
		{
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Category c = new Category();
			IList list = new ArrayList();
			c.Subcategories = list;
			list.Add(new Category());
			s.Save(c);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Category) s.Load(typeof(Category), c.Id, LockMode.Upgrade);
			c.Subcategories = list;
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Category) s.Load(typeof(Category), c.Id, LockMode.Upgrade);
			IList list2 = c.Subcategories;
			t.Commit();
			s.Close();

			Assert.IsFalse(NHibernateUtil.IsInitialized(c.Subcategories));

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Category) s.Load(typeof(Category), c.Id, LockMode.Upgrade);
			c.Subcategories = list2;
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			c = (Category) s.Load(typeof(Category), c.Id, LockMode.Upgrade);
			Assert.AreEqual(1, c.Subcategories.Count);
			s.Delete(c);
			t.Commit();
			s.Close();
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:43,代码来源:MasterDetailTest.cs


示例18: FindBySQLSimpleByDiffSessions

		public void FindBySQLSimpleByDiffSessions()
		{
			if ( dialect is Dialect.MySQLDialect ) return;

			ISession session = OpenSession();
			Category s = new Category();
			nextLong++;
			s.Name = nextLong.ToString();
			session.Save(s);
			session.Flush();
			session.Close();
		
			session = OpenSession();

			IQuery query = session.CreateSQLQuery("select s.category_key_col as {category.id}, s.Name as {category.Name}, s.\"assign able id\" as {category.Assignable} from {category} s", "category", typeof( Category ));
			IList list = query.List();

			Assert.IsNotNull(list);
			Assert.IsTrue(list.Count > 0);
			Assert.IsTrue(list[0] is Category);

			// How do we handle objects that does not have id property (such as Simple ?)
			// How do we handle objects with composite id's ? (such as Single)
			session.Delete( list[0] );
			session.Flush();
			session.Close();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:27,代码来源:SQLLoaderTest.cs


示例19: Copy

		public void Copy()
		{
			Category catWA = new Category();
			catWA.Name = "HSQL workaround";
			Category cat = new Category();
			cat.Name = "foo";
			Category subCatBar = new Category();
			subCatBar.Name = "bar";
			Category subCatBaz = new Category();
			subCatBaz.Name = "baz";
			cat.Subcategories.Add(subCatBar);
			cat.Subcategories.Add(subCatBaz);

			using (ISession s = OpenSession())
			{
				s.Save(catWA);
				s.Save(cat);
				s.Flush();
			}

			cat.Name = "new foo";
			subCatBar.Name = "new bar";
			cat.Subcategories.Remove(subCatBaz);
			Category newCat = new Category();
			newCat.Name = "new";
			cat.Subcategories.Add(newCat);
			Category newSubCat = new Category();
			newSubCat.Name = "new sub";
			newCat.Subcategories.Add(newSubCat);

			Category copiedCat;
			using (ISession s = OpenSession())
			{
				copiedCat = s.Merge(cat);
				s.Flush();
			}
			Assert.IsFalse(copiedCat == cat);
			Assert.IsTrue(cat.Subcategories.Contains(newCat));

			using (ISession s = OpenSession())
			{
				cat = (Category) s.CreateQuery("from Category cat where cat.Name='new foo'").UniqueResult();
				newSubCat = (Category)s.CreateQuery("from Category cat left join fetch cat.Subcategories where cat.Name='new sub'").UniqueResult();
				Assert.AreEqual("new sub", newSubCat.Name);
			}
			newSubCat.Subcategories.Add(cat);
			cat.Name="new new foo";

			using (ISession s = OpenSession())
			{
				newSubCat = s.Merge(newSubCat);
				Assert.IsTrue(newSubCat.Name.Equals("new sub"));
				Assert.AreEqual(1, newSubCat.Subcategories.Count);
				cat	= (Category)newSubCat.Subcategories[0];
				Assert.AreEqual("new new foo", cat.Name);
				newSubCat.Subcategories.Remove(cat);
				s.Delete(cat);
				s.Delete(subCatBaz);
				s.Delete(catWA);
				s.Flush();
			}
		}
开发者ID:NeoDarque,项目名称:nhibernate-core,代码行数:62,代码来源:MasterDetailTest.cs


示例20: NamedSQLQuery

		public void NamedSQLQuery()
		{
			if( dialect is Dialect.MySQLDialect )
			{
				return;
			}

			ISession s = OpenSession();
			
			Category c = new Category();
			c.Name = "NAME";
			Assignable assn = new Assignable();
			assn.Id = "i.d.";
			IList l = new ArrayList();
			l.Add( c );
			assn.Categories = l;
			c.Assignable = assn;
			s.Save( assn );
			s.Flush();
			s.Close();

			s = OpenSession();
			IQuery q = s.GetNamedQuery( "namedsql" );
			Assert.IsNotNull( q, "should have found 'namedsql'" );
			IList list = q.List();
			Assert.IsNotNull( list, "executing query returns list" );

			object[] values = list[0] as object[];
			Assert.IsNotNull( values[0], "index 0 should not be null" );
			Assert.IsNotNull( values[1], "index 1 should not be null" );

			Assert.AreEqual( typeof(Category), values[0].GetType(), "should be a Category" );
			Assert.AreEqual( typeof(Assignable), values[1].GetType(), "should be Assignable" );
			s.Delete( "from Category" );
			s.Delete( "from Assignable" );
			s.Flush();
			s.Close();

		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:39,代码来源:SQLLoaderTest.cs



注:本文中的NHibernate.DomainModel.Category类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DomainModel.Glarch类代码示例发布时间:2022-05-26
下一篇:
C# DomainModel.Baz类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap