private object ProcessSkip(SkipQueryNode skip) { var processedOffset = ProcessNode(skip.Amount); _sparqlModel.Offset = Convert.ToInt32(processedOffset); return(ProcessNode(skip.Collection)); }
/// <summary> /// Processes the skip operator (if any) and returns the combined query. /// </summary> /// <param name="query">The query tree constructed so far.</param> /// <param name="skip">The skip amount or null if none was specified.</param> /// <returns> /// The unmodified <paramref name="query"/> if no skip is specified or the combined /// query tree including the skip operator if it was specified. /// </returns> private static QueryNode ProcessSkip(QueryNode query, int? skip) { ExceptionUtils.CheckArgumentNotNull(query, "query"); if (skip.HasValue) { CollectionQueryNode entityCollection = query.AsEntityCollectionNode(); if (entityCollection == null) { throw new ODataException(Strings.MetadataBinder_SkipNotApplicable); } int skipValue = skip.Value; if (skipValue < 0) { throw new ODataException(Strings.MetadataBinder_SkipRequiresNonNegativeInteger(skipValue.ToString(CultureInfo.CurrentCulture))); } query = new SkipQueryNode() { Collection = entityCollection, Amount = new ConstantQueryNode { Value = skipValue } }; } return query; }
/// <summary> /// Translates a skip operation. /// </summary> /// <param name="skipNode">The skip node to translate.</param> /// <returns>The translated expression which evaluates to the result of the skip operation.</returns> protected virtual Expression TranslateSkip(SkipQueryNode skipNode) { ExceptionUtils.CheckArgumentNotNull(skipNode, "skipNode"); ExceptionUtils.CheckArgumentNotNull(skipNode.Amount, "skipNode.Amount"); Expression collectionExpression = this.Translate(skipNode.Collection); Expression amountExpression = this.Translate(skipNode.Amount); // TODO: eventually we will have to support this on Enumerable as well (as it can happen on expansions) return Expression.Call( typeof(Queryable), SkipMethodName, new Type[] { skipNode.Collection.ItemType.GetInstanceType(this.model) }, collectionExpression, amountExpression); }
private object ProcessSkip(SkipQueryNode skip) { var processedOffset = ProcessNode(skip.Amount); _sparqlModel.Offset = Convert.ToInt32(processedOffset); return ProcessNode(skip.Collection); }