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


C# QueryTranslator.Compile方法代码示例

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


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

示例1: GetSqlWithClassicParser

		public string GetSqlWithClassicParser(string query)
		{
			var qt = new NHibernate.Hql.Classic.QueryTranslator(null, query, emptyfilters, sessions);
			qt.Compile(new Dictionary<string, string>(), false);
			return qt.SQLString;
		}
开发者ID:nkmajeti,项目名称:nhibernate,代码行数:6,代码来源:BaseFixture.cs

示例2: Token

		/// <summary>
		/// 
		/// </summary>
		/// <param name="token"></param>
		/// <param name="q"></param>
		public void Token(string token, QueryTranslator q)
		{
			string lcToken = token.ToLowerInvariant();

			//Cope with [,]

			if (token.Equals("[") && !expectingPathContinuation)
			{
				expectingPathContinuation = false;
				if (expectingIndex == 0)
				{
					throw new QueryException("unexpected [");
				}
				return;
			}
			else if (token.Equals("]"))
			{
				expectingIndex--;
				expectingPathContinuation = true;
				return;
			}

			//Cope with a continued path expression (ie. ].baz)
			if (expectingPathContinuation)
			{
				if (ContinuePathExpression(token, q)) return;
			}

			//Cope with a subselect
			if (!inSubselect && (lcToken.Equals("select") || (lcToken.Equals("from") && !isInSpecialFunctionClause)))
			{
				inSubselect = true;
				subselect = new StringBuilder(20);
			}
			if (inSubselect && token.Equals(StringHelper.ClosedParen))
			{
				bracketsSinceSelect--;

				if (bracketsSinceSelect == -1)
				{
					QueryTranslator subq = new QueryTranslator(q.Factory, subselect.ToString(), q.EnabledFilters);
					try
					{
						subq.Compile(q);
					}
					catch (MappingException me)
					{
						throw new QueryException("MappingException occurred compiling subquery", me);
					}

					AppendToken(q, subq.SqlString);
					inSubselect = false;
					bracketsSinceSelect = 0;
				}
			}
			if (inSubselect)
			{
				if (token.Equals(StringHelper.OpenParen))
				{
					bracketsSinceSelect++;
				}
				subselect.Append(token).Append(' ');
				return;
			}

			//Cope with special cases of AND, NOT, ()
			SpecialCasesBefore(lcToken);

			//Close extra brackets we opened
			if (!betweenSpecialCase && expressionTerminators.Contains(lcToken))
			{
				CloseExpression(q, lcToken);
			}

			//take note when this is a boolean expression

			if (booleanOperators.Contains(lcToken))
			{
				booleanTests.RemoveAt(booleanTests.Count - 1);
				booleanTests.Add(true);
			}

			if (lcToken.Equals("not"))
			{
				nots[nots.Count - 1] = !nots[nots.Count - 1];
				negated = !negated;
				return; //NOTE: early return
			}

			if (!isInSpecialFunctionClause && specialFunctions.Contains(lcToken))
			{
				isInSpecialFunctionClause = true;
			}
			if (isInSpecialFunctionClause && token.Equals(StringHelper.OpenParen))
			{
//.........这里部分代码省略.........
开发者ID:nikson,项目名称:nhibernate-core,代码行数:101,代码来源:WhereParser.cs


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