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


C# SqlLogSpy.GetWholeLog方法代码示例

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


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

示例1: CanOverrideStringEnumGetValue

		public void CanOverrideStringEnumGetValue()
		{
		    string paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix;
			using (ISession s = OpenSession())
			using (ITransaction tx = s.BeginTransaction())
			{
				using (SqlLogSpy ls = new SqlLogSpy())
				{
					Person person = new Person() { Sex = Sex.Male };
					s.Save(person);

					string log = ls.GetWholeLog();
					Assert.IsTrue(log.Contains(paramPrefix + "p0 = 'M'"));
				}

				using (SqlLogSpy ls = new SqlLogSpy())
				{
					Person person =
						s.CreateQuery("from Person p where p.Sex = :personSex")
							.SetParameter("personSex", Sex.Female)
							.UniqueResult<Person>();

					Assert.That(person, Is.Null);

					string log = ls.GetWholeLog();
					Assert.IsTrue(log.Contains(paramPrefix + "p0 = 'F'"));
				}

				tx.Rollback();
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:31,代码来源:Fixture.cs

示例2: WhenPersistShouldNotFetchUninitializedCollection

		public void WhenPersistShouldNotFetchUninitializedCollection()
		{
			var companyId = CreateScenario();

			//Now in a second transaction i remove the address and persist Company: for a cascade option the Address will be removed
			using (var sl = new SqlLogSpy())
			{
				using (ISession session = sessions.OpenSession())
				{
					using (ITransaction tx = session.BeginTransaction())
					{
						var company = session.Get<Company>(companyId);
						company.Addresses.Count().Should().Be.EqualTo(1);
						company.RemoveAddress(company.Addresses.First()).Should().Be.EqualTo(true);

						//now this company will be saved and deleting the address.
						//BUT it should not try to load the BanckAccound collection!
						session.Persist(company);
						tx.Commit();
					}
				}
				var wholeMessage = sl.GetWholeLog();
				wholeMessage.Should().Not.Contain("BankAccount");
			}

			Cleanup(companyId);
		}
开发者ID:owerkop,项目名称:nhibernate-core,代码行数:27,代码来源:Fixture.cs

示例3: DeleteWithoutUpdateVersion

		public void DeleteWithoutUpdateVersion()
		{
			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.Save(new ObjectA { Bs = new List<ObjectB> { new ObjectB(), new ObjectB() } });
				t.Commit();
			}

			using (var ls = new SqlLogSpy())
			{
				using (ISession s = OpenSession())
				using (ITransaction t = s.BeginTransaction())
				{
					var a = s.CreateCriteria<ObjectA>().UniqueResult<ObjectA>();
					s.Delete(a);
					t.Commit();
				}
				string wholeLog = ls.GetWholeLog();
				Assert.That(wholeLog, Is.Not.StringContaining("UPDATE ObjectA"));
				Assert.That(wholeLog, Is.StringContaining("UPDATE ObjectB"),"should create orphans");
			}

			using (ISession s = OpenSession())
			using (ITransaction t = s.BeginTransaction())
			{
				s.CreateQuery("delete from ObjectB").ExecuteUpdate();
				s.CreateQuery("delete from ObjectA").ExecuteUpdate();
				t.Commit();
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:31,代码来源:Fixture.cs

示例4: ComparisonToConstantShouldBeInnerJoin

 public void ComparisonToConstantShouldBeInnerJoin()
 {
     using (var sqlLog = new SqlLogSpy())
     using (var session = OpenSession())
     {
         session.Query<MyBO>().Where(b => b.BO1.I1 == 1).ToList();
         var log = sqlLog.GetWholeLog();
         Assert.AreEqual(0, CountOuterJoins(log));
         Assert.AreEqual(1, CountInnerJoins(log));
     }
 }
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:11,代码来源:InnerJoinFixture.cs

示例5: EqualsNullShouldBeOuterJoin

 public void EqualsNullShouldBeOuterJoin()
 {
     using (var sqlLog = new SqlLogSpy())
     using (var session = OpenSession())
     {
         session.Query<MyBO>().Where(b => b.BO1.BO2 == null).ToList();
         var log = sqlLog.GetWholeLog();
         Assert.AreEqual(1, CountOuterJoins(log));
         Assert.AreEqual(0, CountInnerJoins(log));
     }
 }
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:11,代码来源:InnerJoinFixture.cs

示例6: SelectAllAnimalsShouldPerformJoins

		public void SelectAllAnimalsShouldPerformJoins()
		{
			using (var session = OpenSession())
			using (session.BeginTransaction())
			{
				using (var spy = new SqlLogSpy())
				{
					var list = session.CreateQuery("from Animal").List<Animal>();
					var count = list.Count();
					Assert.AreEqual(3, count);
					Assert.Greater(1, spy.GetWholeLog().Split(new[] {"inner join"}, StringSplitOptions.None).Count());
				}
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:14,代码来源:Fixture.cs

示例7: Bug

		public void Bug()
		{
			using (ISession s = OpenSession())
			{
				long? filter = null;
				using (var ls = new SqlLogSpy())
				{
					s.CreateQuery(@"SELECT c FROM xchild c WHERE (:filternull = true OR c.Parent.A < :filterval)")
						.SetParameter("filternull", !filter.HasValue)
						.SetParameter("filterval", filter.HasValue ? filter.Value : 0).List<xchild>();
					var message = ls.GetWholeLog();
					Assert.That(message, Text.Contains("xchild0_.ParentId=xparent1_.Id and (@p0=1 or xparent1_.A<@p1)"));
				}
			}
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:15,代码来源:Fixture.cs

示例8: ShouldNotContainJoinWhereNotRequired

		public void ShouldNotContainJoinWhereNotRequired()
		{
			using (var session = OpenSession())
			{
				using (var ls = new SqlLogSpy())
				{
					ICriteria criteria = session.CreateCriteria(typeof(Entity1));
					criteria.CreateAlias("Entities2", "ent2", JoinType.InnerJoin);
					criteria.List<Entity1>();
					var sql = ls.GetWholeLog();
					var rx = new Regex(@"\bjoin\b");
					Assert.That(rx.Matches(sql).Count, Is.EqualTo(1));
				}
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:15,代码来源:Fixture.cs

示例9: Bug

		public void Bug()
		{
			using (ISession s = OpenSession())
			{
				long? filter = null;
				using (var ls = new SqlLogSpy())
				{
					s.CreateQuery(@"SELECT c FROM xchild c WHERE (:filternull = true OR c.Parent.A < :filterval)")
						.SetParameter("filternull", !filter.HasValue)
						.SetParameter("filterval", filter.HasValue ? filter.Value : 0).List<xchild>();
					var message = ls.GetWholeLog();
				    string paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix;
					Assert.That(message, Is.StringContaining("xchild0_.ParentId=xparent1_.Id and (" + paramPrefix + "p0=" + Dialect.ToBooleanValueString(true) + " or xparent1_.A<" + paramPrefix + "p1)"));
				}
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:16,代码来源:Fixture.cs

示例10: CanCahceDynamicLinq

		public void CanCahceDynamicLinq()
		{
			//dynamic orderby clause
			var users = db.Users
						  .Cacheable()
						  .Fetch(x => x.Role)
						  .OrderBy("RegisteredAt");

			users
			  .ToList();

			using (var log = new SqlLogSpy())
			{
				users.ToList();
				Assert.IsNullOrEmpty(log.GetWholeLog());
			}
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:17,代码来源:DynamicQueryTests.cs

示例11: SaveCanOverrideStringEnumGetValue

		public void SaveCanOverrideStringEnumGetValue()
		{
			var paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix;
			using (var ls = new SqlLogSpy())
			{
				using (var s = OpenSession())
				using (var t = s.BeginTransaction())
				{
					var person = new Person { Sex = Sex.Male };
					s.Save(person);

					t.Commit();
				}
				
				var log = ls.GetWholeLog();
				Assert.That(log.Contains(paramPrefix + "p0 = 'M'"), Is.True);
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:18,代码来源:Fixture.cs

示例12: WhenQueryConstantNotEqualToMemberThenDoesNotUseTheCaseConstructor

		public void WhenQueryConstantNotEqualToMemberThenDoesNotUseTheCaseConstructor()
		{
			using (new Scenario(Sfi))
			{
				using (var session = OpenSession())
				{
					using (var sqls = new SqlLogSpy())
					{
						Assert.That(session.Query<MyClass>().Where(x => x.Alive != false).ToList(), Has.Count.EqualTo(1));
						Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0));
					}
					using (var sqls = new SqlLogSpy())
					{
						Assert.That(session.Query<MyClass>().Where(x => true != x.Alive).ToList(), Has.Count.EqualTo(1));
						Assert.That(caseClause.Matches(sqls.GetWholeLog()).Count, Is.EqualTo(0));
					}
				}
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:19,代码来源:Fixture.cs

示例13: ReadCanOverrideStringEnumGetValue

		public void ReadCanOverrideStringEnumGetValue()
		{
			var paramPrefix = ((DriverBase) Sfi.ConnectionProvider.Driver).NamedPrefix;
			using (var ls = new SqlLogSpy())
			{
				using (var s = OpenSession())
				using (s.BeginTransaction())
				{
					var person = s.CreateQuery("from Person p where p.Sex = :personSex")
						.SetParameter("personSex", Sex.Female)
						.UniqueResult<Person>();

					Assert.That(person, Is.Null);
				}
			   
				string log = ls.GetWholeLog();
				Assert.IsTrue(log.Contains(paramPrefix + "p0 = 'F'"));
			}
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:19,代码来源:Fixture.cs

示例14: WhenQueryConstantNotEqualToMemberThenDoesNotUseTheCaseConstructor

		public void WhenQueryConstantNotEqualToMemberThenDoesNotUseTheCaseConstructor()
		{
			using (new Scenario(Sfi))
			{
				using (var session = OpenSession())
				{
					using (var sqls = new SqlLogSpy())
					{
						session.Query<MyClass>().Where(x => x.Alive != false).Should().Have.Count.EqualTo(1);
						caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0);
					}
					using (var sqls = new SqlLogSpy())
					{
						session.Query<MyClass>().Where(x => true != x.Alive).Should().Have.Count.EqualTo(1);
						caseClause.Matches(sqls.GetWholeLog()).Count.Should().Be(0);
					}
				}
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:19,代码来源:Fixture.cs

示例15: TheJoinShouldBeOptional

		public void TheJoinShouldBeOptional()
		{
			FillDb();
			int criteriaCount;

			using (ISession session = OpenSession())
			{
				using (var ls = new SqlLogSpy())
				{
					ICriteria c = session.CreateCriteria(typeof(TestClass));
					IList<TestClass> retvalue = c.List<TestClass>();
					Assert.That(ls.GetWholeLog(), Is.Not.StringContaining("join"));
					criteriaCount = retvalue.Count;
				}
			}
			Assert.That(criteriaCount, Is.EqualTo(1));

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


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