public void AddToClause(QueueItem clause) { const string invalidQueryText = "invalid query"; if (clause is null) { throw new ArgumentException(invalidQueryText); } else if (clause.Representation == TextRepresentation.ListOfExpands || clause.Representation == TextRepresentation.ListOfSortings) { foreach (var child in clause.Children.Select(x => x.Item2)) { AddToClause(child); } } else if (clause.Representation == TextRepresentation.SortProperty) { var direction = clause.Children.Last().Item2.Root.Value.Text == "asc" ? SortDirection.Ascending : SortDirection.Descending; var child = clause.Children.First().Item2; ResultList.Add(ITuple.Create(SelectClauseParser <TRootQueryType> .PathAndPropertyFromExpandItem(child, Graph, RootQueryType), direction)); } else if (clause.Representation == TextRepresentation.ExpandProperty) { ResultList.Add(ITuple.Create(SelectClauseParser <TRootQueryType> .PathAndPropertyFromExpandItem(clause, Graph, RootQueryType), SortDirection.Ascending)); } else { throw new ArgumentException($"{invalidQueryText} - Unrecognized term: {clause.Root.Value.Text}"); } }
public void AddToClause(QueueItem clause) { if (Result is null) { Result = clause; } else { var and = new TextInfo("and", TextRepresentation.LogicalComparison); var rootAnd = new ParserVertex(and); var childrenWithEdges = new[] { ITuple.Create(new ParserEdge(rootAnd, clause.Root), clause), ITuple.Create(new ParserEdge(rootAnd, Result.Root), Result) }; Result = new QueueItem(rootAnd, childrenWithEdges); } }