當前位置: 首頁>>代碼示例>>C#>>正文


C# SqlBuilder.GetStatement方法代碼示例

本文整理匯總了C#中SqlBuilder.GetStatement方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlBuilder.GetStatement方法的具體用法?C# SqlBuilder.GetStatement怎麽用?C# SqlBuilder.GetStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SqlBuilder的用法示例。


在下文中一共展示了SqlBuilder.GetStatement方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Init

		public void Init()
		{
			GentleSettings.CacheObjects = false;
			CacheManager.Clear();
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MultiType) );
			Broker.Execute( sb.GetStatement( true ) );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:7,代碼來源:TestMultiType.cs

示例2: TestCRUD

		public void TestCRUD()
		{
			// skip test if GUIDs are not supported by database backend
			if( runTest )
			{
				o1 = new GuidHolder( 42 );
				// insert
				o1.Persist();
				// select
				o2 = GuidHolder.Retrieve( o1.Id );
				// verify select/insert
				Assert.IsNotNull( o2.Id, "The object could not be retrieved from the database!" );
				Assert.AreEqual( o1.Id, o2.Id, "The object could not be retrieved from the database!" );
				Assert.AreEqual( o1.SomeValue, o2.SomeValue, "The object could not be retrieved from the database!" );
				// update
				o2.SomeValue = 1234;
				o2.Persist();
				// verify update
				o1 = GuidHolder.Retrieve( o2.Id );
				Assert.AreEqual( o2.Id, o1.Id, "The object could not be retrieved from the database!" );
				// delete
				o2.Remove();
				// verify delete by counting the number of rows
				SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(GuidHolder) );
				sb.AddConstraint( Operator.Equals, "Id", o1.Id );
				SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
				Assert.AreEqual( 0, sr.Count, "Object not removed" );
			}
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:29,代碼來源:TestGuid.cs

示例3: GetCount

		private int GetCount( SqlBuilder builder )
		{
			SqlStatement statement = builder.GetStatement();
			SqlResult result = statement.Execute();
			int count = result.Count;
			return count;
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:7,代碼來源:TestConstraint.cs

示例4: Init

		public void Init()
		{
			GentleSettings.CacheObjects = false;
			CacheManager.Clear();
			// make sure table is empty before we start
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(PropertyHolder) );
			Broker.Execute( sb.GetStatement( true ) );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:8,代碼來源:TestPropertyHolder.cs

示例5: Final

		public void Final()
		{
			if( runTest )
			{
				SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberPicture) );
				Broker.Execute( sb.GetStatement( true ) );
			}
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:8,代碼來源:TestMemberPicture.cs

示例6: Final

		public void Final()
		{
			// make sure we have only the default 4 members 
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberSD) );
			sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
			Broker.Execute( sb.GetStatement( true ) );
			// remove the list
			list.Remove();
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:9,代碼來源:TestMemberSD.cs

示例7: CleanUp

		public void CleanUp()
		{
			if( runTests )
			{
				SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(ReservedWords) );
				SqlStatement stmt = sb.GetStatement( true );
				stmt.Execute();
			}
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:9,代碼來源:TestReservedWords.cs

示例8: GetRawTableData

		private SqlResult GetRawTableData()
		{
			SqlBuilder sb = new SqlBuilder( StatementType.Select, typeof(PHNullableType) );
			SqlStatement stmt = sb.GetStatement( true );
			// override generated statement to make sure we execute this without any type association
			stmt = new SqlStatement( StatementType.Select, Broker.Provider.GetCommand(), stmt.Sql );
			SqlResult sr = stmt.Execute();
			return sr;
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:9,代碼來源:TestPHNullableType.cs

示例9: Init

		public void Init()
		{
			// make sure we have only 4 members 
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(Member) );
			sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
			Broker.Execute( sb.GetStatement( true ) );
			// make sure we have only 3 lists 
			sb = new SqlBuilder( StatementType.Delete, typeof(MailingList) );
			sb.AddConstraint( Operator.GreaterThan, "Id", 3 );
			Broker.Execute( sb.GetStatement( true ) );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:11,代碼來源:TestConstraint.cs

示例10: Init

		public void Init()
		{
			// make sure we have only 4 members 
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(MemberCC) );
			sb.AddConstraint( Operator.GreaterThan, "Id", 4 );
			Broker.Execute( sb.GetStatement( true ) );
			// make sure we have only 3 lists 
			sb = new SqlBuilder( StatementType.Delete, typeof(MailingList) );
			sb.AddConstraint( Operator.GreaterThan, "Id", 3 );
			Broker.Execute( sb.GetStatement( true ) );
			// create an empty mailing list
			list = new MailingList( "SomeList", "[email protected]" );
			list.Persist();
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:14,代碼來源:TestMemberCC.cs

示例11: Init

		public void Init()
		{
			// disable query caching
			GentleSettings.SkipQueryExecution = false;
			// clean any existing entries
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(UserRole) );
			Broker.Execute( sb.GetStatement() );
			// clean out roles table 
			sb = new SqlBuilder( StatementType.Delete, typeof(Role) );
			Broker.Execute( sb.GetStatement() );
			// populate table with known roles
			fixedRoles = new Role[Enum.GetNames( typeof(Roles) ).Length];
			int index = 0;
			foreach( string roleName in Enum.GetNames( typeof(Roles) ) )
			{
				Role role = new Role( (Roles) Enum.Parse( typeof(Roles), roleName, false ) );
				role.Persist();
				fixedRoles[ index++ ] = role;
			}
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:20,代碼來源:TestUser.cs

示例12: TestCRUD_Dog

		public void TestCRUD_Dog()
		{
			o1 = new Dog();
			// insert
			o1.Persist();
			Assert.IsTrue( o1.Id > 0, "No identity assigned on insert." );
			// select
			o2 = Dog.Retrieve( o1.Id );
			// verify select/insert
			Assert.IsNotNull( o2.Id, "The object could not be retrieved from the database!" );
			Assert.AreEqual( o1.Id, o2.Id, "The object could not be retrieved from the database!" );
			// update
			o2.Persist();
			// verify update
			o1 = Dog.Retrieve( o2.Id );
			// delete
			o2.Remove();
			// verify delete by counting the number of rows
			SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(Dog) );
			sb.AddConstraint( Operator.Equals, "Id", o1.Id );
			SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
			Assert.AreEqual( 0, sr.Count, "Object not removed" );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:23,代碼來源:TestMultiType.cs

示例13: TestCRUD

		public void TestCRUD()
		{
			a = new PropertyHolder( 0, "MyPH", 2, 3, 4, 5.0, true, DateTime.Now, DateTime.Now,
			                        "char", "nchar", "varchar", "nvarchar", "text", "ntext" );
			// insert
			a.Persist();
			Assert.AreEqual( a.Name, "MyPH" );
			// select
			b = PropertyHolder.Retrieve( a.Id );
			// verify select/insert
			Assert.IsTrue( b.Id != 0 );
			Assert.AreEqual( a.Id, b.Id );
			Assert.AreEqual( "MyPH", b.Name );
			// update
			b.Name = "NewPH";
			b.TDateTime = DateTime.MinValue; // should result in DBNull being written
			b.Persist();
			// verify update
			a = Broker.RetrieveInstance( typeof(PropertyHolder), b.GetKey() ) as PropertyHolder;
			Assert.AreEqual( b.Name, a.Name );
			Assert.AreEqual( DateTime.MinValue, a.TDateTime );
			// delete
			b.Remove();
			// verify delete by counting the number of rows
			SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(PropertyHolder) );
			sb.AddConstraint( Operator.Equals, "Id", a.Id );
			SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
			Assert.AreEqual( 0, sr.Count, "Object not removed" );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:29,代碼來源:TestPropertyHolder.cs

示例14: Exit

		public void Exit()
		{
			// clean up after running tests
			SqlBuilder sb = new SqlBuilder( StatementType.Delete, typeof(PropertyHolder) );
			Broker.Execute( sb.GetStatement( true ) );
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:6,代碼來源:TestPropertyHolder.cs

示例15: TestCRUD

		public void TestCRUD()
		{
			// skip test if picture data was not read (check the PATH constant above!)
			if( runTest && picture != null )
			{
				mp1 = new MemberPicture( picture, 1 );
				// insert
				mp1.Persist();
				Assert.AreEqual( mp1.MemberId, 1, "The object was not properly inserted!" );
				Assert.AreEqual( GetSize( mp1.Picture ), pictureSize, "The object was not properly inserted!" );
				// select
				mp2 = MemberPicture.Retrieve( mp1.Id );
				// verify select/insert
				Assert.IsNotNull( mp2.Id, "The object could not be retrieved from the database!" );
				Assert.AreEqual( mp1.Id, mp2.Id, "The object could not be retrieved from the database!" );
				Assert.AreEqual( pictureSize, GetSize( mp2.Picture ), "The object was not properly retrieved on construction!" );
				Assert.AreEqual( mp1.MemberId, mp2.MemberId,
				                 "The object was not properly retrieved on construction!" );
				// update
				mp2.MemberId = 2;
				mp2.Persist();
				// verify update
				mp1 = MemberPicture.Retrieve( mp2.Id );
				Assert.AreEqual( mp2.MemberId, mp1.MemberId, "MemberId not updated!" );
				// delete
				mp2.Remove();
				// verify delete by counting the number of rows
				SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(MemberPicture) );
				sb.AddConstraint( Operator.Equals, "Id", mp1.Id );
				SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
				Assert.AreEqual( 0, sr.Count, "Object not removed" );
			}
		}
開發者ID:arangas,項目名稱:MediaPortal-1,代碼行數:33,代碼來源:TestMemberPicture.cs


注:本文中的SqlBuilder.GetStatement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。