public Document GetCollection() { ///////////////////////////////////////////////////// // Get all Blogs from repository ///////////////////////////////////////////////////// var blogs = BloggingRepository.GetBlogs(); ///////////////////////////////////////////////////// // Build JSON API document ///////////////////////////////////////////////////// var currentRequestUri = this.Request.GetUri(); using (var documentContext = new BloggingDocumentContext(currentRequestUri)) { var document = documentContext .NewDocument(currentRequestUri) .SetJsonApiVersion(JsonApiVersion.Version10) .Links() .AddUpLink() .AddSelfLink() .LinksEnd() .ResourceCollection(blogs) .Relationships() .AddRelationship("articles", new[] { Keywords.Related }) .RelationshipsEnd() .Links() .AddSelfLink() .LinksEnd() .ResourceCollectionEnd() .WriteDocument(); return(document); } }