当前位置: 首页>>代码示例>>C#>>正文


C# SqlString.LastIndexOfCaseInsensitive方法代码示例

本文整理汇总了C#中NHibernate.SqlCommand.SqlString.LastIndexOfCaseInsensitive方法的典型用法代码示例。如果您正苦于以下问题:C# SqlString.LastIndexOfCaseInsensitive方法的具体用法?C# SqlString.LastIndexOfCaseInsensitive怎么用?C# SqlString.LastIndexOfCaseInsensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.SqlCommand.SqlString的用法示例。


在下文中一共展示了SqlString.LastIndexOfCaseInsensitive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveAsAliasesFromSql

		public static SqlString RemoveAsAliasesFromSql(SqlString sql)
		{
			return sql.Substring(0, sql.LastIndexOfCaseInsensitive(" as "));
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:4,代码来源:StringHelper.cs

示例2: GetPrevTableInsertPoint

		private static int GetPrevTableInsertPoint(SqlString text)
		{
			int i = text.LastIndexOfCaseInsensitive("from");
			int j = text.LastIndexOfCaseInsensitive(",");
			if (i == -1 && j == -1)
			{
				return -1;
			}
			if (j > i)
			{
				return j + 1;
			}
			return i + 5;
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:14,代码来源:InformixJoinFragment.cs

示例3: GetLimitString

		/// <summary>
		/// Add a <c>LIMIT</c> clause to the given SQL <c>SELECT</c>
		/// </summary>
		/// <param name="querySqlString">The <see cref="SqlString"/> to base the limit query off.</param>
		/// <param name="offset">Offset of the first row to be returned by the query (zero-based)</param>
		/// <param name="limit">Maximum number of rows to be returned by the query</param>
		/// <param name="offsetParameterIndex">Optionally, the Offset parameter index</param>
		/// <param name="limitParameterIndex">Optionally, the Limit parameter index</param>
		/// <returns>A new <see cref="SqlString"/> with the <c>LIMIT</c> clause applied.</returns>
		/// <remarks>
		/// Note that we need to explicitly specify the columns, because we need to be able to use them in a paged subselect [NH-1155]
		/// </remarks>
		public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit, int? offsetParameterIndex, int? limitParameterIndex)
		{
			SqlStringBuilder result = new SqlStringBuilder();
						
			if (offset == 0)
			{
				int insertPoint = this.GetAfterSelectInsertPoint(querySqlString);
				
				return result
					.Add(querySqlString.Substring(0, insertPoint))
					.Add(" TOP (")
					.Add(limitParameterIndex == null ? Parameter.Placeholder : Parameter.WithIndex(limitParameterIndex.Value))
					.Add(")")
					.Add(querySqlString.Substring(insertPoint))
					.ToSqlString();
			}

			int fromIndex = GetFromIndex(querySqlString);
			SqlString select = querySqlString.Substring(0, fromIndex);

			List<SqlString> columnsOrAliases;
			Dictionary<SqlString, SqlString> aliasToColumn;
			ExtractColumnOrAliasNames(select, out columnsOrAliases, out aliasToColumn);
		
			int orderIndex = querySqlString.LastIndexOfCaseInsensitive(" order by ");
			SqlString fromAndWhere;
			SqlString[] sortExpressions;

			//don't use the order index if it is contained within a larger statement(assuming 
			//a statement with non matching parenthesis is part of a larger block)
			if (orderIndex > 0 && HasMatchingParens(querySqlString.Substring(orderIndex).ToString()))
			{
				fromAndWhere = querySqlString.Substring(fromIndex, orderIndex - fromIndex).Trim();
				SqlString orderBy = querySqlString.Substring(orderIndex).Trim();
				sortExpressions = orderBy.Substring(9).Split(",");
			}
			else
			{
				fromAndWhere = querySqlString.Substring(fromIndex).Trim();
				// Use dummy sort to avoid errors
				sortExpressions = new[] {new SqlString("CURRENT_TIMESTAMP"),};
			}				
				
			result
				.Add("SELECT TOP (")
				.Add(limitParameterIndex == null ? Parameter.Placeholder : Parameter.WithIndex(limitParameterIndex.Value))
				.Add(") ")
				.Add(StringHelper.Join(", ", columnsOrAliases))
				.Add(" FROM (")
				.Add(select)
				.Add(", ROW_NUMBER() OVER(ORDER BY ");
			
			AppendSortExpressions(aliasToColumn, sortExpressions, result);

			result
				.Add(") as __hibernate_sort_row ")
				.Add(fromAndWhere)
				.Add(") as query WHERE query.__hibernate_sort_row > ")
				.Add(offsetParameterIndex == null ? Parameter.Placeholder : Parameter.WithIndex(offsetParameterIndex.Value))
				.Add(" ORDER BY query.__hibernate_sort_row");
			
			return result.ToSqlString();
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:75,代码来源:MsSql2005Dialect.cs

示例4: RemoveAsAliasesFromSql

		public static SqlString RemoveAsAliasesFromSql(SqlString sql)
		{
			int index = sql.LastIndexOfCaseInsensitive(" as ");
			if (index < 0) return sql;
			return sql.Substring(0, index);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:6,代码来源:SqlStringHelper.cs


注:本文中的NHibernate.SqlCommand.SqlString.LastIndexOfCaseInsensitive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。