本文整理汇总了C#中NHibernate.SqlCommand.SqlString.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.Insert方法的具体用法?C# SqlString.Insert怎么用?C# SqlString.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.SqlCommand.SqlString
的用法示例。
在下文中一共展示了SqlString.Insert方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public static SqlString Apply(SqlString sql)
{
if (text == null)
return sql;
var s = "from " + theTable;
var index = sql.IndexOfCaseInsensitive(s);
var indexOfSpaceAfterAlias = sql.IndexOf(" ", index + s.Length +1, sql.Length, StringComparison.InvariantCultureIgnoreCase);
if (indexOfSpaceAfterAlias == -1)
return sql;
return sql.Insert(indexOfSpaceAfterAlias, text);
}
示例2: PrependComment
private static SqlString PrependComment(SqlString sql, QueryParameters parameters)
{
string comment = parameters.Comment;
if (string.IsNullOrEmpty(comment))
{
return sql;
}
else
{
return sql.Insert(0, "/* " + comment + " */");
}
}
示例3: GetLimitString
public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)
{
/*
* "SELECT TOP limit rest-of-sql-statement"
*/
SqlStringBuilder topFragment = new SqlStringBuilder();
topFragment.Add(" top ");
topFragment.Add(limit);
return querySqlString.Insert(GetAfterSelectInsertPoint(querySqlString), topFragment.ToSqlString());
}
示例4: GetLimitString
public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)
{
var top = new SqlStringBuilder()
.Add(" top (")
.Add(limit)
.Add(")")
.ToSqlString();
return querySqlString.Insert(GetAfterSelectInsertPoint(querySqlString), top);
}
示例5: GetLimitString
/// <summary>
/// Add a <c>LIMIT (TOP)</c> clause to the given SQL <c>SELECT</c>
/// </summary>
/// <param name="querySqlString">A Query in the form of a SqlString.</param>
/// <param name="limit">Maximum number of rows to be returned by the query</param>
/// <param name="offset">Offset of the first row to process in the result set</param>
/// <returns>A new SqlString that contains the <c>LIMIT</c> clause.</returns>
public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
{
if (offset > 0)
{
throw new NotSupportedException("SQL Server does not support an offset");
}
/*
* "SELECT TOP limit rest-of-sql-statement"
*/
return querySqlString.Insert(GetAfterSelectInsertPoint(querySqlString), " top " + limit);
}
示例6: GetLimitString
public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
{
int intSelectInsertPoint = GetAfterSelectInsertPoint(querySqlString);
string strLimit = string.Format(" top {0} start at {1}", limit, offset + 1);
return querySqlString.Insert(intSelectInsertPoint, strLimit);
}
示例7: GetLimitString
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
{
// FIXME - This should use the ROWS syntax in Firebird to avoid problems with subqueries metioned here:
// http://www.firebirdsql.org/refdocs/langrefupd20-select.html#langrefupd20-first-skip
/*
* "SELECT FIRST x [SKIP y] rest-of-sql-statement"
*/
int insertIndex = GetAfterSelectInsertPoint(queryString);
SqlStringBuilder limitFragment = new SqlStringBuilder();
if (limit != null)
{
limitFragment.Add(" first ");
limitFragment.Add(limit);
}
if (offset != null)
{
limitFragment.Add(" skip ");
limitFragment.Add(offset);
}
return queryString.Insert(insertIndex, limitFragment.ToSqlString());
}
示例8: GetLimitString
/// <summary>
/// Add a <c>FIRST x [SKIP] y</c> clause to the given SQL <c>SELECT</c>
/// </summary>
/// <param name="querySqlString">A Query in the form of a SqlString.</param>
/// <param name="limit">Maximum number of rows to be returned by the query</param>
/// <param name="offset">Offset of the first row to process in the result set</param>
/// <returns>A new SqlString that contains the <c>FIRST</c> clause.</returns>
public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
{
/*
* "SELECT FIRST x [SKIP y] rest-of-sql-statement"
*/
int insertIndex = GetAfterSelectInsertPoint(querySqlString);
if (offset > 0)
{
return querySqlString.Insert(insertIndex, " first " + limit.ToString() + " skip " + offset.ToString());
}
else
{
return querySqlString.Insert(insertIndex, " first " + limit.ToString());
}
}
示例9: Insert
public void Insert()
{
SqlString sql = new SqlString(new object[] { "begin ", Parameter.Placeholder, " end" });
Assert.AreEqual("beginning ? end", sql.Insert(5, "ning").ToString());
Assert.AreEqual("begin middle? end", sql.Insert(6, "middle").ToString());
Assert.AreEqual("begin ?middle end", sql.Insert(7, "middle").ToString());
Assert.AreEqual("beg|in ? end", sql.Insert(3, "|").ToString());
Assert.AreEqual("begin ? ending", sql.Insert(11, "ing").ToString());
Assert.AreEqual("begin ? enXd", sql.Insert(10, "X").ToString());
}
示例10: GetLimitString
public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)
{
var tokenEnum = new SqlTokenizer(querySqlString).GetEnumerator();
if (!tokenEnum.TryParseUntilFirstMsSqlSelectColumn()) return null;
int insertPoint = tokenEnum.Current.SqlIndex;
return querySqlString.Insert(insertPoint, new SqlString("top ", limit, " "));
}
示例11: GetLimitString
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
{
/*
* "SELECT [SKIP x] FIRST y rest-of-sql-statement"
*/
// TODO - Check support for cases where only the offset is specified, but the limit is not. Might need to use int.MaxValue.
int insertIndex = GetAfterSelectInsertPoint(queryString);
SqlStringBuilder limitFragment = new SqlStringBuilder();
if (offset != null)
{
limitFragment.Add(" skip ");
limitFragment.Add(offset);
}
if (limit != null)
{
limitFragment.Add(" first ");
limitFragment.Add(limit);
}
return queryString.Insert(insertIndex, limitFragment.ToSqlString());
}
示例12: GetLimitString
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
{
if (offset != null && offset.Length != 0)
throw new NotSupportedException("Jet Engine 4.0 does not support an offset");
int insertIndex = GetAfterSelectInsertPoint(queryString);
var limitFragment = new SqlStringBuilder();
if (limit != null && limit.Length != 0)
{
limitFragment.Add(" TOP ");
limitFragment.Add(limit);
}
return queryString.Insert(insertIndex, limitFragment.ToSqlString());
}
示例13: GetLimitString
public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)
{
var top = new SqlString(" top (", limit, ")");
return querySqlString.Insert(GetAfterSelectInsertPoint(querySqlString), top);
}
示例14: GetLimitString
public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
{
int intSelectInsertPoint = GetAfterSelectInsertPoint(queryString);
SqlStringBuilder limitFragment = new SqlStringBuilder();
limitFragment.Add(" top ");
if (limit != null)
limitFragment.Add(limit);
else
limitFragment.Add(int.MaxValue.ToString());
if (offset != null)
{
limitFragment.Add(" start at ");
limitFragment.Add(offset);
}
return queryString.Insert(intSelectInsertPoint, limitFragment.ToSqlString());
}