/// <summary> /// Annotates the given payload based on the metadata in the given uri /// </summary> /// <param name="rootElement">The payload to annotate with metadata information</param> /// <param name="uri">The uri that corresponds to the given payload</param> public void ResolveMetadata(ODataPayloadElement rootElement, ODataUri uri) { ExceptionUtilities.CheckArgumentNotNull(rootElement, "rootElement"); ExceptionUtilities.CheckArgumentNotNull(uri, "uri"); this.InitializeMetadataStack(uri); this.InitialStackSize = this.MetadataStack.Count; rootElement.Add(new ExpectedPayloadElementTypeAnnotation() { ExpectedType = uri.GetExpectedPayloadType() }); // if the uri did not contain any metadata, do nothing if (this.InitialStackSize > 0) { // if this is the result of service operation or action, the root element needs to have the function itself and its return type var serviceOperation = this.MetadataStack.OfType <Function>().FirstOrDefault(); if (serviceOperation != null) { rootElement.AddAnnotationIfNotExist(new FunctionAnnotation() { Function = serviceOperation }); rootElement.AddAnnotationIfNotExist(new DataTypeAnnotation() { DataType = serviceOperation.ReturnType }); } this.Recurse(rootElement); } }
internal static bool ResponseMightIncludeNextLink(ODataUri uri) { var payloadsWithNextLinks = new[] { ODataPayloadElementType.EntitySetInstance, ODataPayloadElementType.LinkCollection }; var expectedPayloadType = uri.GetExpectedPayloadType(); if (!payloadsWithNextLinks.Contains(expectedPayloadType)) { return(false); } EntitySet expectedSet; ExceptionUtilities.Assert(uri.TryGetExpectedEntitySet(out expectedSet), "Could not get expected entity set"); var pageSize = expectedSet.GetEffectivePageSize(); if (!pageSize.HasValue) { return(false); } // if the value of $top is less than 1 page size, no next link will be included return(!uri.Top.HasValue || uri.Top.Value > pageSize.Value); }