本文整理汇总了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
//.........这里部分代码省略.........
示例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;
//.........这里部分代码省略.........