当前位置: 首页>>代码示例>>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;未经允许,请勿转载。