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


C# SqlString.IndexOfCaseInsensitive方法代码示例

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


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

示例1: GetLimitString

		public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
		{
			if (querySqlString.IndexOfCaseInsensitive(" ORDER BY ") < 0)
			{
				querySqlString = querySqlString.Append(" ORDER BY GETDATE()");
			}
			return querySqlString.Append(string.Format(" OFFSET {0} ROWS FETCH NEXT {1} ROWS ONLY", offset, limit));
		}
开发者ID:pontillo,项目名称:PowerNap,代码行数:8,代码来源:MsSqlCe40Dialect.cs

示例2: 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);
        }
开发者ID:ayende,项目名称:course-jul-25,代码行数:12,代码来源:Optimizations.cs

示例3: GetLimitString

		public override SqlString GetLimitString(SqlString queryString, SqlString offset, SqlString limit)
		{
			var builder = new SqlStringBuilder(queryString);
			if (queryString.IndexOfCaseInsensitive(" ORDER BY ") < 0)
				builder.Add(" ORDER BY GETDATE()");

			builder.Add(" OFFSET ");
			if (offset == null)
				builder.Add("0");
			else
				builder.Add(offset);
			builder.Add(" ROWS");

			if (limit != null)
			{
				builder.Add(" FETCH NEXT ");
				builder.Add(limit);
				builder.Add(" ROWS ONLY");
			}

			return builder.ToSqlString();
		}
开发者ID:rbirkby,项目名称:nhibernate-core,代码行数:22,代码来源:MsSqlCe40Dialect.cs

示例4: ApplyLocksToSql

		public override SqlString ApplyLocksToSql(SqlString sql, IDictionary<string, LockMode> aliasedLockModes, IDictionary<string, string[]> keyColumnNames)
		{
			// TODO:  merge additional lockoptions support in Dialect.applyLocksToSql

			var buffer = new StringBuilder(sql.ToString());
			int correction = 0;
			
			foreach (KeyValuePair<string, LockMode> entry in aliasedLockModes)
			{
				LockMode mode = entry.Value;
				
				if (mode.GreaterThan(LockMode.Read))
				{
					string alias = entry.Key;
					int start = -1;
					int end = -1;
					
					if (sql.EndsWith(" " + alias))
					{
						start = (sql.Length - alias.Length) + correction;
						end = start + alias.Length;
					}
					else
					{
						int position = sql.IndexOfCaseInsensitive(" " + alias + " ");
						
						if (position <= -1)
							position = sql.IndexOfCaseInsensitive(" " + alias + ",");
						
						if (position > -1)
						{
							start = position + correction + 1;
							end = start + alias.Length;
						}
					}
					
					if (start > -1)
					{
						string lockHint = AppendLockHint(mode, alias);
						buffer.Remove(start, end - start + 1);
						buffer.Insert(start, lockHint);
						correction += (lockHint.Length - alias.Length);
					}
				}
			}
			return new SqlString(buffer.ToString());
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:47,代码来源:SybaseASE15Dialect.cs

示例5: IndexOfNonCompacted

		public void IndexOfNonCompacted()
		{
			SqlString str = new SqlString(new object[] { "select ", " from" });
			Assert.AreEqual(6, str.IndexOfCaseInsensitive("  "));
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:5,代码来源:SqlStringFixture.cs

示例6: IndexOf

		public void IndexOf()
		{
			SqlString str =
				new SqlString(new object[] { "select ", Parameter.Placeholder, " from table where x = ", Parameter.Placeholder });

			Assert.AreEqual(0, str.IndexOfCaseInsensitive("select"));
			Assert.AreEqual(1, str.IndexOfCaseInsensitive("el"));

			Assert.AreEqual(7 + 1 + 6, str.IndexOfCaseInsensitive("table"));
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:10,代码来源:SqlStringFixture.cs

示例7: HasCollectionFilterParam

		private static bool HasCollectionFilterParam(SqlString sqlFragment)
		{
			return sqlFragment.IndexOfCaseInsensitive("?") < 0;
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:4,代码来源:JoinProcessor.cs

示例8: HasDynamicFilterParam

		private static bool HasDynamicFilterParam(SqlString sqlFragment)
		{
			return sqlFragment.IndexOfCaseInsensitive(ParserHelper.HqlVariablePrefix) < 0;
		}
开发者ID:NikGovorov,项目名称:nhibernate-core,代码行数:4,代码来源:JoinProcessor.cs

示例9: GetFromIndex

		private static int GetFromIndex(SqlString querySqlString)
		{
			string subselect = querySqlString.GetSubselectString().ToString();
			int fromIndex = querySqlString.IndexOfCaseInsensitive(subselect);
			if (fromIndex == -1)
			{
				fromIndex = querySqlString.ToString().ToLowerInvariant().IndexOf(subselect.ToLowerInvariant());
			}
			return fromIndex;
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:10,代码来源:MsSql2005Dialect.cs

示例10: FinalizeJoins

        /// <summary>
        ///Jet engine has the following from clause syntax:
        ///<code>
        ///     tableexpression[, tableexpression]*
        ///</code>
        ///where tableexpression is:
        ///<code>
        ///     tablename [(INNER |LEFT | RIGHT) JOIN [(] tableexpression [)] ON ...]
        ///</code>
        ///where the parenthesises are necessary if the "inner" tableexpression is not just a single tablename.
        ///Additionally INNER JOIN cannot be nested in LEFT | RIGHT JOIN.
        ///To translate the simple non-parenthesized joins to the jet syntax, the following transformation must be done:
        ///<code>
        ///     A join B on ... join C on ... join D on ..., E join F on ... join G on ..., H join I on ..., J
        ///has to be translated as:
        ///     (select * from ((A join B on ...) join C on ...) join D on ...) as crazyAlias1, (select * from (E join F on ...) join G on ...) as crazyAlias2, (select * from H join I on ...) as crazyAlias3, J
        ///</code>
        /// </summary>
        /// <param name="sqlString">the sqlstring to transform</param>
        /// <returns>sqlstring with parenthesized joins.</returns>
        private SqlString FinalizeJoins(SqlString sqlString)
        {
            if (_queryCache.Contains(sqlString))
            {
                return (SqlString)_queryCache[sqlString];
            }

            var beginOfFrom = sqlString.IndexOfCaseInsensitive(FromClause);
            var endOfFrom = sqlString.IndexOfCaseInsensitive(WhereClause);
            var beginOfOrderBy = sqlString.IndexOfCaseInsensitive(OrderByClause);

            if (beginOfFrom < 0)
            {
                return sqlString;
            }

            if (beginOfOrderBy < 0)
            {
                if (endOfFrom < 0)
                {
                    endOfFrom = sqlString.Length;
                }
            }
            else
            {
                endOfFrom = beginOfOrderBy;
            }

            var fromClause = sqlString.Substring(beginOfFrom, endOfFrom - beginOfFrom).ToString();
            var wherePart = sqlString.Substring(endOfFrom);
            var fromClauseInWhere = wherePart.IndexOfCaseInsensitive(FromClause);
            var transformedFrom = TransformFromClause(fromClause);
            var processWhereJoins = string.Empty;

            if (fromClauseInWhere > -1) //has where clause, inspect other joins
            {
                var whereClause = wherePart.Substring(0, fromClauseInWhere);
                var criteria = wherePart.Substring(fromClauseInWhere).ToString();

                processWhereJoins = whereClause + TransformFromClause(criteria);
            }

            //put it all together again
            var final = new SqlStringBuilder(sqlString.Count + 1);
            final.Add(sqlString.Substring(0, beginOfFrom));
            final.Add(transformedFrom);

            if (string.IsNullOrEmpty(processWhereJoins))
            {
                final.Add(sqlString.Substring(endOfFrom));
            }
            else
            {
                final.Add(processWhereJoins);
            }

            SqlString ret = final.ToSqlString();
            RestoreMissingParameters(sqlString, ref ret);
            _queryCache[sqlString] = ret;

            return ret;
        }
开发者ID:deAtog,项目名称:nhcontrib,代码行数:82,代码来源:JetDriver.cs

示例11: FinalizeJoins

        /// <summary>
        ///Jet engine has the following from clause syntax:
        ///<code>
        ///		tableexpression[, tableexpression]*
        ///</code>
        ///where tableexpression is:
        ///<code>
        ///		tablename [(INNER |LEFT | RIGHT) JOIN [(] tableexpression [)] ON ...]
        ///</code>
        ///where the parenthesises are necessary if the "inner" tableexpression is not just a single tablename.
        ///Additionally INNER JOIN cannot be nested in LEFT | RIGHT JOIN.
        ///To translate the simple non-parenthesized joins to the jet syntax, the following transformation must be done:
        ///<code>
        ///		A join B on ... join C on ... join D on ..., E join F on ... join G on ..., H join I on ..., J
        ///has to be translated as:
        ///		(select * from ((A join B on ...) join C on ...) join D on ...) as crazyAlias1, (select * from (E join F on ...) join G on ...) as crazyAlias2, (select * from H join I on ...) as crazyAlias3, J
        ///</code>
        /// </summary>
        /// <param name="sqlString">the sqlstring to transform</param>
        /// <returns>sqlstring with parenthesized joins.</returns>
        private SqlString FinalizeJoins(SqlString sqlString)
        {
            if (_queryCache.Contains(sqlString))
            {
                return (SqlString) _queryCache[sqlString];
            }

            var beginOfFrom = sqlString.IndexOfCaseInsensitive(FromClause);
            var endOfFrom = sqlString.IndexOfCaseInsensitive(WhereClause);
            var beginOfOrderBy = sqlString.IndexOfCaseInsensitive(OrderByClause);

            if (beginOfFrom < 0)
            {
                return sqlString;
            }

            if (beginOfOrderBy < 0)
            {
                if (endOfFrom < 0)
                {
                    endOfFrom = sqlString.Length;
                }
            }
            else
            {
                endOfFrom = beginOfOrderBy;
            }

            var fromClause = sqlString.Substring(beginOfFrom, endOfFrom - beginOfFrom).ToString();
            var transformedFrom = TransformFromClause(fromClause);

            //put it all together again
            var final = new SqlStringBuilder(sqlString.Count + 1);
            final.Add(sqlString.Substring(0, beginOfFrom));
            final.Add(transformedFrom);
            final.Add(sqlString.Substring(endOfFrom));

            SqlString ret = final.ToSqlString();
            _queryCache[sqlString] = ret;

            return ret;
        }
开发者ID:pruiz,项目名称:nhibernate-contrib-old,代码行数:62,代码来源:JetDriver.cs


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