本文整理汇总了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");
}
示例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);
}
示例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));
}
示例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" );
}