當前位置: 首頁>>代碼示例>>C#>>正文


C# QueryTranslator.AppendScalarSelectToken方法代碼示例

本文整理匯總了C#中NHibernate.Hql.Classic.QueryTranslator.AppendScalarSelectToken方法的典型用法代碼示例。如果您正苦於以下問題:C# QueryTranslator.AppendScalarSelectToken方法的具體用法?C# QueryTranslator.AppendScalarSelectToken怎麽用?C# QueryTranslator.AppendScalarSelectToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NHibernate.Hql.Classic.QueryTranslator的用法示例。


在下文中一共展示了QueryTranslator.AppendScalarSelectToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Token

		public void Token(string token, QueryTranslator q)
		{
			SessionFactoryHelper helper = new SessionFactoryHelper(q.Factory);
			string lctoken = token.ToLowerInvariant();

			if (first)
			{
				first = false;
				if ("distinct".Equals(lctoken))
				{
					q.Distinct = true;
					return;
				}
				else if ("all".Equals(lctoken))
				{
					q.Distinct = false;
					return;
				}
			}

			if (afterNew)
			{
				afterNew = false;
				holderClass = helper.GetImportedClass(token);
				if (holderClass == null)
				{
					throw new QueryException("class not found: " + token);
				}
				q.HolderClass = holderClass;
				insideNew = true;
			}
			else if (token.Equals(StringHelper.Comma))
			{
				if (readyForAliasOrExpression)
				{
					throw new QueryException("alias or expression expected in SELECT");
				}
				q.AppendScalarSelectToken(StringHelper.CommaSpace);
				readyForAliasOrExpression = true;
			}
			else if ("new".Equals(lctoken))
			{
				afterNew = true;
				readyForAliasOrExpression = false;
			}
			else if (StringHelper.OpenParen.Equals(token))
			{
				parenCount++;
				if (!funcStack.HasFunctions && holderClass != null && !readyForAliasOrExpression)
				{
					//opening paren in new Foo ( ... )
					readyForAliasOrExpression = true;
				}
				else if (funcStack.HasFunctions)
				{
					q.AppendScalarSelectToken(token);
				}
				else
				{
					throw new QueryException("HQL function expected before '(' in SELECT clause.");
				}
				readyForAliasOrExpression = true;
			}
			else if (StringHelper.ClosedParen.Equals(token))
			{
				parenCount--;
				if (parenCount < 0)
				{
					throw new QueryException("'(' expected before ')' in SELECT clause.");
				}

				if (insideNew && !funcStack.HasFunctions && !readyForAliasOrExpression)
				{
					//if we are inside a new Result(), but not inside a nested function
					insideNew = false;
				}
				else if (funcStack.HasFunctions)
				{
					q.AppendScalarSelectToken(token);
					IType scalarType = funcStack.GetReturnType();
					funcStack.Pop();

					// Can't have an alias or expression right after the closing parenthesis of a function call.
					readyForAliasOrExpression = false;

					// if all functions were parsed add the type of the first function in stack
					if (!funcStack.HasFunctions)
						q.AddSelectScalar(scalarType);
				}
			}
			else if (IsHQLFunction(lctoken, q) && token == q.Unalias(token))
			{
				if (!readyForAliasOrExpression && !funcStack.HasFunctions)
				{
					// The syntax control inside a functions is delegated to the render
					throw new QueryException("',' expected before function in SELECT: " + token);
				}
				if (funcStack.HasFunctions && funcStack.FunctionGrammar.IsKnownArgument(lctoken))
				{
					// Some function, like extract, may have KnownArgument with the same name of another function
//.........這裏部分代碼省略.........
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:101,代碼來源:SelectParser.cs

示例2: Token

		/// <summary>
		/// 
		/// </summary>
		/// <param name="token"></param>
		/// <param name="q"></param>
		public void Token(string token, QueryTranslator q)
		{
			string lctoken = token.ToLower(CultureInfo.InvariantCulture);

			if (first)
			{
				first = false;
				if (lctoken.Equals("distinct"))
				{
					q.Distinct = true;
					return;
				}
				else if (lctoken.Equals("all"))
				{
					q.Distinct = false;
					return;
				}
			}

			if (afterNew)
			{
				afterNew = false;
				holderClass = SessionFactoryHelper.GetImportedClass(q.Factory, token);
				if (holderClass == null)
				{
					throw new QueryException("class not found: " + token);
				}
				q.HolderClass = holderClass;
				insideNew = true;
			}
			else if (token.Equals(StringHelper.Comma))
			{
				if (ready)
				{
					throw new QueryException("alias or expression expected in SELECT");
				}
				q.AppendScalarSelectToken(StringHelper.CommaSpace);
				ready = true;
			}
			else if ("new".Equals(lctoken))
			{
				afterNew = true;
				ready = false;
			}
			else if (StringHelper.OpenParen.Equals(token))
			{
				if (!aggregate && holderClass != null && !ready)
				{
					//opening paren in new Foo ( ... )
					ready = true;
				}
				else if (aggregate)
				{
					q.AppendScalarSelectToken(token);
				}
				else
				{
					throw new QueryException("aggregate function expected before ( in SELECT");
				}
				ready = true;
			}
			else if (StringHelper.ClosedParen.Equals(token))
			{
				if (insideNew && !aggregate && !ready)
				{
					//if we are inside a new Result(), but not inside a nested function
					insideNew = false;
				}
				else if (aggregate && ready)
				{
					q.AppendScalarSelectToken(token);
					aggregateFuncTokenList.RemoveAt(0);
					if (aggregateFuncTokenList.Count < 1)
					{
						aggregate = false;
						ready = false;
					}
				}
				else
				{
					throw new QueryException("( expected before ) in select");
				}
			}
			else if (countArguments.Contains(lctoken))
			{
				if (!ready || !aggregate)
				{
					throw new QueryException(token + " only allowed inside aggregate function in SELECT");
				}
				q.AppendScalarSelectToken(token);
				if ("*".Equals(token) && !afterAggregatePath)
				{
					q.AddSelectScalar(GetFunction("count", q).ReturnType(NHibernateUtil.Int64, q.Factory));
				} //special case
				afterAggregatePath = false;
//.........這裏部分代碼省略.........
開發者ID:Novthirteen,項目名稱:sconit_timesseiko,代碼行數:101,代碼來源:SelectParser.cs


注:本文中的NHibernate.Hql.Classic.QueryTranslator.AppendScalarSelectToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。