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


C# SqlString.Replace方法代碼示例

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


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

示例1: Replace

		public void Replace()
		{
			SqlString sql =
				new SqlString(
					new object[] {"select ", "from table ", "where a = ", Parameter.Placeholder, " and c = ", Parameter.Placeholder});
			SqlString replacedSql = sql.Replace("table", "replacedTable");
			Assert.AreEqual(sql.ToString().Replace("table", "replacedTable"), replacedSql.ToString());

			replacedSql = sql.Replace("not found", "not in here");
			Assert.AreEqual(sql.ToString().Replace("not found", "not in here"), replacedSql.ToString(), "replace no found string");

			replacedSql = sql.Replace("le", "LE");
			Assert.AreEqual(sql.ToString().Replace("le", "LE"), replacedSql.ToString(), "multi-match replace");
		}
開發者ID:Ruhollah,項目名稱:nhibernate-core,代碼行數:14,代碼來源:SqlStringFixture.cs

示例2: GetAfterSelectInsertPoint

        private int GetAfterSelectInsertPoint(SqlString sql)
        {
            const string criteriaComment = "/* criteria query */ ";

            if (sql.StartsWithCaseInsensitive(criteriaComment))
                return GetAfterSelectInsertPoint(criteriaComment.Length, sql.Replace(criteriaComment, String.Empty));
            else
                return GetAfterSelectInsertPoint(0, sql);
        }
開發者ID:AndyCC,項目名稱:Jumbleblocks-website,代碼行數:9,代碼來源:MsSql2008FixedDialect.cs

示例3: GetLimitString

 /// <summary>
 /// MS Access and SQL Server support limit. This implementation has been made according the MS Access syntax
 /// </summary>
 /// <param name="querySqlString">The original query</param>
 /// <param name="offset">Specifies the number of rows to skip, before starting to return rows from the query expression.</param>
 /// <param name="limit">Is used to limit the number of results returned in a SQL statement</param>
 /// <returns>Processed query</returns>
 public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
 {
     return querySqlString.Replace("select", string.Format("select top {0}", limit));
 }
開發者ID:nhibernate,項目名稱:NHibernate.JetDriver,代碼行數:11,代碼來源:JetDialect.cs

示例4: Replace

		public void Replace() 
		{
			SqlString sql = new SqlString( new object[] {"select ", "from table ", "where a = ", new Parameter( "p1" ), " and c = ", new Parameter( "p2" ) } );
			
			SqlString replacedSql = sql.Replace( "table", "replacedTable" );
			Assert.AreEqual( "select from replacedTable where a = ", replacedSql.SqlParts[0], "replaced single instance" );

			replacedSql = sql.Replace( "not found", "not in here" );
			Assert.AreEqual( sql.ToString(), replacedSql.ToString(), "replace no found string" );

			replacedSql = sql.Replace( "le", "LE" );
			Assert.AreEqual( "seLEct from tabLE where a = ", replacedSql.SqlParts[0], "multi-match replace" );
			Assert.IsTrue( replacedSql.SqlParts[1] is Parameter, "multi-match replace - Param 1" );
			Assert.AreEqual(" and c = ", replacedSql.SqlParts[2], "multi-match replace" );
			Assert.IsTrue( replacedSql.SqlParts[3] is Parameter, "multi-match replace - Param 2" );
			
		}
開發者ID:rcarrillopadron,項目名稱:nhibernate-1.0.2.0,代碼行數:17,代碼來源:SqlStringFixture.cs


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