private Expression VisitMember <T>(T node, Func <T, Expression> baseCaller) where T : Expression { var queryField = memberAccessBuilder.GetFieldOrNull(node); if (queryField == null) { return(baseCaller(node)); } rootIsSingleItem = ReferenceEquals(node, xRoot); var fieldIndex = -1; for (var i = 0; i < fields.Count; i++) { if (fields[i].Path == queryField.Path) { fieldIndex = i; break; } } if (fieldIndex < 0) { fields.Add(queryField); fieldIndex = fields.Count - 1; } items.Add(new SelectedPropertyItem(null, fieldIndex)); return(node); }
public override void VisitOrdering(Ordering ordering, QueryModel queryModel, OrderByClause orderByClause, int index) { base.VisitOrdering(ordering, queryModel, orderByClause, index); var field = memberAccessBuilder.GetFieldOrNull(ordering.Expression); if (field == null) { throw new InvalidOperationException("order by must have field reference"); } var fieldOrdering = new FieldOrdering { Field = new FieldReferenceExpression { Field = field.Expression, CustomId = CustomFieldHelpers.ExtractIdentifier(field.Expression) }, Order = ordering.OrderingDirection == OrderingDirection.Asc ? JqlOrderType.Asc : JqlOrderType.Desc }; queryBuilder.AppendOrdering(fieldOrdering); }