当前位置: 首页>>代码示例>>C#>>正文


C# TestData.Cleanup方法代码示例

本文整理汇总了C#中TestData.Cleanup方法的典型用法代码示例。如果您正苦于以下问题:C# TestData.Cleanup方法的具体用法?C# TestData.Cleanup怎么用?C# TestData.Cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestData的用法示例。


在下文中一共展示了TestData.Cleanup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WithClauseFailsWithFetch

		public void WithClauseFailsWithFetch()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction txn = s.BeginTransaction();

			Assert.Throws<SemanticException>(
			  () =>
				s.CreateQuery("from Animal a inner join fetch a.offspring as o with o.bodyWeight = :someLimit").SetDouble(
					"someLimit", 1).List(), "ad-hoc on clause allowed with fetched association");

			txn.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:18,代码来源:WithClauseFixture.cs

示例2: SimpleInsert

		public void SimpleInsert()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			s.CreateQuery("insert into Pickup (id, Vin, Owner) select id, Vin, Owner from Car").ExecuteUpdate();

			t.Commit();
			t = s.BeginTransaction();

			s.CreateQuery("delete Vehicle").ExecuteUpdate();

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:20,代码来源:BulkManipulation.cs

示例3: InsertWithManyToOne

		public void InsertWithManyToOne()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			s.CreateQuery(
				"insert into Animal (description, bodyWeight, mother) select description, bodyWeight, mother from Human").
				ExecuteUpdate();

			t.Commit();
			t = s.BeginTransaction();

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:20,代码来源:BulkManipulation.cs

示例4: DeleteUnionSubclassAbstractRoot

		public void DeleteUnionSubclassAbstractRoot()
		{
			var data = new TestData(this);
			data.Prepare();

			// These should reach out into *all* subclass tables...
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("delete Vehicle where Owner = :owner").SetString("owner", "Steve").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "incorrect restricted update count");

			count = s.CreateQuery("delete Vehicle").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(3), "incorrect update count");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:20,代码来源:BulkManipulation.cs

示例5: DeleteOnMappedJoin

		public void DeleteOnMappedJoin()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count =
				s.CreateQuery("delete Joiner where joinedName = :joinedName").SetString("joinedName", "joined-name").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined class");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:17,代码来源:BulkManipulation.cs

示例6: InsertWithMismatchedTypes

		public void InsertWithMismatchedTypes()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			Assert.Throws<QueryException>(
			  () => s.CreateQuery("insert into Pickup (Owner, Vin, id) select id, Vin, Owner from Car").ExecuteUpdate(),
				"mismatched types did not error");

			t.Commit();
			t = s.BeginTransaction();

			s.CreateQuery("delete Vehicle").ExecuteUpdate();

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:21,代码来源:BulkManipulation.cs

示例7: DeleteOnJoinedSubclass

		public void DeleteOnJoinedSubclass()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("delete Mammal where bodyWeight > 150").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass");

			count = s.CreateQuery("delete Mammal").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect deletion count on joined subclass");

			count = s.CreateQuery("delete SubMulti").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(0), "Incorrect deletion count on joined subclass");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:22,代码来源:BulkManipulation.cs

示例8: DeleteOnDiscriminatorSubclass

		public void DeleteOnDiscriminatorSubclass()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("delete PettingZoo").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count");

			count = s.CreateQuery("delete Zoo").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass delete count");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:19,代码来源:BulkManipulation.cs

示例9: InsertAcrossMappedJoinFails

		public void InsertAcrossMappedJoinFails()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			Assert.Throws<QueryException>(
				() => s.CreateQuery("insert into Joiner (name, joinedName) select vin, owner from Car").ExecuteUpdate(),
				"mapped-join insertion did not error");

			t.Commit();
			t = s.BeginTransaction();

			s.CreateQuery("delete Joiner").ExecuteUpdate();
			s.CreateQuery("delete Vehicle").ExecuteUpdate();

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:23,代码来源:BulkManipulation.cs

示例10: UpdateOnMammal

		public void UpdateOnMammal()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("update Mammal set description = description").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");

			count = s.CreateQuery("update Mammal set bodyWeight = 25").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");

			if (! (Dialect is MySQLDialect))
			{
				// MySQL does not support (even un-correlated) subqueries against the update-mutating table
				count = s.CreateQuery("update Mammal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate();
				Assert.That(count, Is.EqualTo(2), "incorrect update count against 'middle' of joined-subclass hierarchy");
			}

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:26,代码来源:BulkManipulation.cs

示例11: UpdateMultiplePropertyOnAnimal

		public void UpdateMultiplePropertyOnAnimal()
		{
			var data = new TestData(this);
			data.Prepare();

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				int count =
					s.CreateQuery("update Animal set description = :newDesc, bodyWeight = :w1 where description = :desc")
						.SetString("desc", data.Polliwog.Description)
						.SetString("newDesc", "Tadpole")
						.SetSingle("w1", 3)
						.ExecuteUpdate();
				
				Assert.That(count, Is.EqualTo(1));
				t.Commit();
			}

			using (ISession s = OpenSession())
			using (s.BeginTransaction())
			{
				var tadpole = s.Get<Animal>(data.Polliwog.Id);
				Assert.That(tadpole.Description, Is.EqualTo("Tadpole"));
				Assert.That(tadpole.BodyWeight, Is.EqualTo(3));
			}

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:29,代码来源:BulkManipulation.cs

示例12: UpdateOnAnimal

		public void UpdateOnAnimal()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			int count =
				s.CreateQuery("update Animal set description = description where description = :desc")
				.SetString("desc", data.Frog.Description)
				.ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect entity-updated count");

			count =
				s.CreateQuery("update Animal set description = :newDesc where description = :desc")
				.SetString("desc",data.Polliwog.Description)
				.SetString("newDesc", "Tadpole")
				.ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect entity-updated count");

			var tadpole = s.Load<Animal>(data.Polliwog.Id);

			Assert.That(tadpole.Description, Is.EqualTo("Tadpole"), "Update did not take effect");

			count =
				s.CreateQuery("update Animal set bodyWeight = bodyWeight + :w1 + :w2")
				.SetSingle("w1", 1)
				.SetSingle("w2", 2)
				.ExecuteUpdate();
			Assert.That(count, Is.EqualTo(6), "incorrect count on 'complex' update assignment");

			if (! (Dialect is MySQLDialect))
			{
				// MySQL does not support (even un-correlated) subqueries against the update-mutating table
				s.CreateQuery("update Animal set bodyWeight = ( select max(bodyWeight) from Animal )").ExecuteUpdate();
			}

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:42,代码来源:BulkManipulation.cs

示例13: UpdateOnDiscriminatorSubclass

		public void UpdateOnDiscriminatorSubclass()
		{
			var data = new TestData(this);
			data.Prepare();

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("update PettingZoo set name = name").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");

			t.Rollback();
			t = s.BeginTransaction();

			count =
				s.CreateQuery("update PettingZoo pz set pz.name = pz.name where pz.id = :id").SetInt64("id", data.PettingZoo.Id).
					ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");

			t.Rollback();
			t = s.BeginTransaction();

			count = s.CreateQuery("update Zoo as z set z.name = z.name").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(2), "Incorrect discrim subclass update count");

			t.Rollback();
			t = s.BeginTransaction();

			// TODO : not so sure this should be allowed.  Seems to me that if they specify an alias,
			// property-refs should be required to be qualified.
			count = s.CreateQuery("update Zoo as z set name = name where id = :id").SetInt64("id", data.Zoo.Id).ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:38,代码来源:BulkManipulation.cs

示例14: DeleteUnionSubclassLeafSubclass

		public void DeleteUnionSubclassLeafSubclass()
		{
			var data = new TestData(this);
			data.Prepare();

			// These should only affect the given table
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("delete Car where Owner = :owner").SetString("owner", "Kirsten").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(1), "incorrect restricted update count");

			count = s.CreateQuery("delete Car").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(0), "incorrect update count");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:20,代码来源:BulkManipulation.cs

示例15: UpdateSetNullUnionSubclass

		public void UpdateSetNullUnionSubclass()
		{
			var data = new TestData(this);
			data.Prepare();

			// These should reach out into *all* subclass tables...
			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();

			int count = s.CreateQuery("update Vehicle set Owner = 'Steve'").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");
			count = s.CreateQuery("update Vehicle set Owner = null where Owner = 'Steve'").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");

			count = s.CreateQuery("delete Vehicle where Owner is null").ExecuteUpdate();
			Assert.That(count, Is.EqualTo(4), "incorrect restricted update count");

			t.Commit();
			s.Close();

			data.Cleanup();
		}
开发者ID:nhibernate,项目名称:nhibernate-core,代码行数:22,代码来源:BulkManipulation.cs


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