private bool ContinuePathExpression(string token, QueryTranslator q) { expectingPathContinuation = false; PathExpressionParser.CollectionElement element = pathExpressionParser.LastCollectionElement(); if (token.StartsWith(".")) { // the path expression continues after a ] DoPathExpression(GetElementName(element, q) + token, q); // careful with this! AddToCurrentJoin(element); return(true); //NOTE: EARLY EXIT! } else { // the path expression ends at the ] if (element.ElementColumns.Length != 1) { throw new QueryException("path expression ended in composite collection element"); } AppendToken(q, element.ElementColumns[0]); AddToCurrentJoin(element); return(false); } }
private string GetElementName(PathExpressionParser.CollectionElement element, QueryTranslator q) { string name; if (element.IsOneToMany) { name = element.Alias; } else { IType type = element.Type; if (type.IsEntityType) { //ie. a many-to-many string clazz = ((EntityType)type).GetAssociatedEntityName(); name = pathExpressionParser.ContinueFromManyToMany(clazz, element.ElementColumns, q); } else { throw new QueryException("illegally dereferenced collection element"); } } return(name); }
private void AddToCurrentJoin(PathExpressionParser.CollectionElement ce) { try { AddToCurrentJoin(ce.JoinSequence.ToJoinFragment().ToWhereFragmentString + ce.IndexValue.ToSqlString()); } catch (MappingException me) { throw new QueryException(me); } }
/// <summary> /// /// </summary> /// <param name="q"></param> public void End(QueryTranslator q) { if (expectingPathContinuation) { expectingPathContinuation = false; PathExpressionParser.CollectionElement element = pathExpressionParser.LastCollectionElement(); if (element.ElementColumns.Length != 1) { throw new QueryException("path expression ended in composite collection element"); } AppendToken(q, element.ElementColumns[0]); AddToCurrentJoin(element); } Token(StringHelper.ClosedParen, q); }