當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。