Skip to content

Commit

Permalink
Add count/nextpagelink on ODataCollectionStart. And make sure they're…
Browse files Browse the repository at this point in the history
… written into response.
  • Loading branch information
James-Bao authored and lewischeng-ms committed Jun 11, 2015
1 parent b6df4e2 commit 5b03cc4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ internal void WriteCollectionStart(ODataCollectionStart collectionStart, IEdmTyp
// "@odata.context":...
this.WriteContextUriProperty(ODataPayloadKind.Collection, () => ODataContextUrlInfo.Create(collectionStart.SerializationInfo, itemTypeReference));

// "@odata.count":...
if (collectionStart.Count.HasValue)
{
this.JsonWriter.WriteInstanceAnnotationName(ODataAnnotationNames.ODataCount);
this.JsonWriter.WriteValue(collectionStart.Count.Value);
}

// "@odata.nextlink":...
if (collectionStart.NextPageLink != null)
{
this.JsonWriter.WriteInstanceAnnotationName(ODataAnnotationNames.ODataNextLink);
this.JsonWriter.WriteValue(this.UriToString(collectionStart.NextPageLink));
}

// "value":
this.JsonWriter.WriteValuePropertyName();
}
Expand Down
18 changes: 18 additions & 0 deletions src/Microsoft.OData.Core/ODataCollectionStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Microsoft.OData.Core
{
using System;

This comment has been minimized.

Copy link
@congysu

congysu Jun 22, 2015

Contributor

Nit: This using can be out side of namespace.


/// <summary>
/// OData representation of a top-level collection.
/// </summary>
Expand All @@ -23,6 +25,22 @@ public string Name
get;
set;
}

/// <summary>Gets or sets the number of items in the feed.</summary>
/// <returns>The number of items in the feed.</returns>
public long? Count
{
get;
set;
}

/// <summary>Gets or sets the URI representing the next page link.</summary>
/// <returns>The URI representing the next page link.</returns>
public Uri NextPageLink
{
get;
set;
}

/// <summary>
/// Provides additional serialization information to the <see cref="ODataCollectionWriter"/> for this <see cref="ODataCollectionStart"/>.
Expand Down

0 comments on commit 5b03cc4

Please sign in to comment.