/// <summary> /// Constructs a $apply filter transformation. /// E.g. $apply=filter(Amount gt 1) /// </summary> /// <param name="applyQueryOptionExpr">ApplyQueryOptionExpression expression</param> /// <returns>A filter transformation</returns> private string ConstructFilterTransformation(ApplyQueryOptionExpression applyQueryOptionExpr) { if (applyQueryOptionExpr.PredicateConjuncts.Count == 0) { return(string.Empty); } return("filter(" + this.ExpressionToString(applyQueryOptionExpr.GetPredicate(), /*inPath*/ false) + ")"); }
/// <summary> /// ApplyQueryOptionExpression visit method. /// </summary> /// <param name="applyQueryOptionExpr">ApplyQueryOptionExpression expression to visit</param> internal void VisitQueryOptionExpression(ApplyQueryOptionExpression applyQueryOptionExpr) { if (applyQueryOptionExpr.Aggregations.Count == 0) { return; } // E.g. filter(Amount gt 1) string filterTransformation = ConstructFilterTransformation(applyQueryOptionExpr); // E.g. aggregate(Prop with sum as SumProp, Prop with average as AverageProp) string aggregateTransformation = ConstructAggregateTransformation(applyQueryOptionExpr.Aggregations); string applyExpression = string.IsNullOrWhiteSpace(filterTransformation) ? string.Empty : filterTransformation + "/"; applyExpression += aggregateTransformation; this.AddAsCachedQueryOption(UriHelper.DOLLARSIGN + UriHelper.OPTIONAPPLY, applyExpression); }