本文整理汇总了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;
}
}
示例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;
}
}