本文整理汇总了C#中NHibernate.SqlCommand.SqlString.EndsWithCaseInsensitive方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.EndsWithCaseInsensitive方法的具体用法?C# SqlString.EndsWithCaseInsensitive怎么用?C# SqlString.EndsWithCaseInsensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.SqlCommand.SqlString
的用法示例。
在下文中一共展示了SqlString.EndsWithCaseInsensitive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLimitString
public override SqlString GetLimitString(SqlString sql, SqlString offset, SqlString limit)
{
sql = sql.Trim();
bool isForUpdate = false;
if (sql.EndsWithCaseInsensitive(" for update"))
{
sql = sql.Substring(0, sql.Length - 11);
isForUpdate = true;
}
string selectColumns = ExtractColumnOrAliasNames(sql);
var pagingSelect = new SqlStringBuilder(sql.Parts.Count + 10);
if (offset != null)
{
pagingSelect.Add("select " + selectColumns + " from ( select row_.*, rownum rownum_ from ( ");
}
else
{
pagingSelect.Add("select " + selectColumns + " from ( ");
}
pagingSelect.Add(sql);
if (offset != null && limit != null)
{
pagingSelect.Add(" ) row_ where rownum <=").Add(limit).Add(") where rownum_ >").Add(offset);
}
else if (limit != null)
{
pagingSelect.Add(" ) where rownum <=").Add(limit);
}
else
{
// offset is specified, but limit is not.
pagingSelect.Add(" ) row_ ) where rownum_ >").Add(offset);
}
if (isForUpdate)
{
pagingSelect.Add(" for update");
}
return pagingSelect.ToSqlString();
}
示例2: GetLimitString
public override SqlString GetLimitString(SqlString sql, int offset, int limit, int? offsetParameterIndex, int? limitParameterIndex)
{
sql = sql.Trim();
bool hasOffset = offset > 0;
bool isForUpdate = false;
if (sql.EndsWithCaseInsensitive(" for update"))
{
sql = sql.Substring(0, sql.Length - 11);
isForUpdate = true;
}
var pagingSelect = new SqlStringBuilder(sql.Parts.Count + 10);
if (hasOffset)
{
pagingSelect.Add("select * from ( select row_.*, rownum rownum_ from ( ");
}
else
{
pagingSelect.Add("select * from ( ");
}
pagingSelect.Add(sql);
if (hasOffset)
{
pagingSelect.Add(" ) row_ where rownum <=").AddParameter(limitParameterIndex.Value).Add(") where rownum_ >").AddParameter(offsetParameterIndex.Value);
}
else
{
pagingSelect.Add(" ) where rownum <=").AddParameter(limitParameterIndex.Value);
}
if (isForUpdate)
{
pagingSelect.Add(" for update");
}
return pagingSelect.ToSqlString();
}