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


C# QueryTranslator.AppendScalarSelectTokens方法代码示例

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


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

示例1: Token


//.........这里部分代码省略.........
				}
			}
			else if (funcStack.HasFunctions)
			{
				bool constantToken = false;
				var expectedParen = parenCount + ((insideNew) ? -1 : 0);
				if (!readyForAliasOrExpression && expectedParen != funcStack.NestedFunctionCount)
				{
					throw new QueryException("'(' expected after HQL function in SELECT");
				}
				try
				{
					ParserHelper.Parse(funcStack.PathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
				}
				catch (QueryException)
				{
					if (IsPathExpression(token))
						throw;
					// If isn't a path the token is added like part of function arguments
					constantToken = true;
				}

				if (token.StartsWith(ParserHelper.HqlVariablePrefix))
				{
					q.AddNamedParameter(token.Substring(1));
					q.AppendScalarSelectParameter();
				}
				else if (constantToken)
				{
					q.AppendScalarSelectToken(token);
				}
				else
				{
					if (funcStack.PathExpressionParser.IsCollectionValued)
					{
						q.AddCollection(
							funcStack.PathExpressionParser.CollectionName,
							funcStack.PathExpressionParser.CollectionRole);
					}
					q.AppendScalarSelectToken(funcStack.PathExpressionParser.WhereColumn);
					funcStack.PathExpressionParser.AddAssociation(q);
				}
				// after a function argument
				readyForAliasOrExpression = false;
			}
			else
			{
				if (!readyForAliasOrExpression)
				{
					throw new QueryException("',' expected in SELECT before:" + token);
				}

				try
				{
					//High probablly to find a valid pathExpression
					ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
					if (pathExpressionParser.IsCollectionValued)
					{
						q.AddCollection(
							pathExpressionParser.CollectionName,
							pathExpressionParser.CollectionRole);
					}
					else if (pathExpressionParser.WhereColumnType.IsEntityType)
					{
						q.AddSelectClass(pathExpressionParser.SelectName);
					}
					q.AppendScalarSelectTokens(pathExpressionParser.WhereColumns);
					q.AddSelectScalar(pathExpressionParser.WhereColumnType);
					pathExpressionParser.AddAssociation(q);
				}
				catch (QueryException)
				{
					// Accept costants in SELECT: NH-280
					// TODO: Parse a costant expression like 5+3+8 (now is not supported in SELECT)
					if (IsStringCostant(token))
					{
						q.AppendScalarSelectToken(token);
						q.AddSelectScalar(NHibernateUtil.String);
					}
					else if (IsIntegerConstant(token))
					{
						q.AppendScalarSelectToken(token);
						q.AddSelectScalar(GetIntegerConstantType(token));
					}
					else if (IsFloatingPointConstant(token))
					{
						q.AppendScalarSelectToken(token);
						q.AddSelectScalar(GetFloatingPointConstantType());
					}
					else if (token.StartsWith(ParserHelper.HqlVariablePrefix))
					{
						q.AddNamedParameter(token.Substring(1));
						q.AppendScalarSelectParameter();
					}
					else
						throw;
				}
				readyForAliasOrExpression = false;
			}
		}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:101,代码来源:SelectParser.cs

示例2: Token


//.........这里部分代码省略.........
				if ("*".Equals(token) && !afterAggregatePath)
				{
					q.AddSelectScalar(GetFunction("count", q).ReturnType(NHibernateUtil.Int64, q.Factory));
				} //special case
				afterAggregatePath = false;
			}
			else if (GetFunction(lctoken, q) != null && token == q.Unalias(token))
			{
				// the name of an SQL function
				if (!ready)
				{
					throw new QueryException(", expected before aggregate function in SELECT: " + token);
				}
				aggregate = true;
				afterAggregatePath = false;
				aggregateAddSelectScalar = true;
				aggregateFuncTokenList.Insert(0, lctoken);
				ready = false;
				q.AppendScalarSelectToken(token);
				if (!AggregateHasArgs(lctoken, q))
				{
					q.AddSelectScalar(AggregateType(aggregateFuncTokenList, null, q));
					if (!AggregateFuncNoArgsHasParenthesis(lctoken, q))
					{
						aggregateFuncTokenList.RemoveAt(0);
						if (aggregateFuncTokenList.Count < 1)
						{
							aggregate = false;
							ready = false;
						}
						else
						{
							ready = true;
						}
					}
				}
			}
			else if (aggregate)
			{
				bool constantToken = false;
				if (!ready)
				{
					throw new QueryException("( expected after aggregate function in SELECT");
				}
				try
				{
					ParserHelper.Parse(aggregatePathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
				}
				catch (QueryException)
				{
					constantToken = true;
				}
				afterAggregatePath = true;

				if (constantToken)
				{
					q.AppendScalarSelectToken(token);
				}
				else
				{
					if (aggregatePathExpressionParser.IsCollectionValued)
					{
						q.AddCollection(
							aggregatePathExpressionParser.CollectionName,
							aggregatePathExpressionParser.CollectionRole);
					}
					q.AppendScalarSelectToken(aggregatePathExpressionParser.WhereColumn);
					if (aggregateAddSelectScalar)
					{
						q.AddSelectScalar(AggregateType(aggregateFuncTokenList, aggregatePathExpressionParser.WhereColumnType, q));
						aggregateAddSelectScalar = false;
					}
					aggregatePathExpressionParser.AddAssociation(q);
				}
			}
			else
			{
				if (!ready)
				{
					throw new QueryException(", expected in SELECT");
				}

				ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q);
				if (pathExpressionParser.IsCollectionValued)
				{
					q.AddCollection(
						pathExpressionParser.CollectionName,
						pathExpressionParser.CollectionRole);
				}
				else if (pathExpressionParser.WhereColumnType.IsEntityType)
				{
					q.AddSelectClass(pathExpressionParser.SelectName);
				}
				q.AppendScalarSelectTokens(pathExpressionParser.WhereColumns);
				q.AddSelectScalar(pathExpressionParser.WhereColumnType);
				pathExpressionParser.AddAssociation(q);

				ready = false;
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:101,代码来源:SelectParser.cs


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