/// <summary>
        /// Return a collection of children of an item referenced by item-id
        /// </summary>
        /// <param name="itemReference"></param>
        /// <param name="childrenRetrievalOptions"></param>
        /// <returns></returns>
        public async Task<ODItemCollection> GetChildrenOfItemAsync(ODItemReference itemReference, ChildrenRetrievalOptions childrenRetrievalOptions)
        {
            if (!itemReference.IsValid())
                throw new ArgumentException("ItemReference was invalid. Requires either an ID or Path");

            var queryParams = ODataOptionsToQueryString(childrenRetrievalOptions);
            Uri serviceUri = UriForItemReference(itemReference, ApiConstants.ChildrenRelationshipName, queryParams);
            return await DataModelForRequest<ODItemCollection>(serviceUri, ApiConstants.HttpGet);
        }
Exemple #2
0
        /// <summary>
        /// Returns a paged children collection for the item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static async Task<ODItemCollection> PagedChildrenCollectionAsync(this ODItem item, ODConnection connection, ChildrenRetrievalOptions options)
        {
            if (item.Children == null)
            {
                var firstPage = await connection.GetChildrenOfItemAsync(item.ItemReference(), options);
                item.Children = firstPage.Collection;
                item.ChildrenNextLinkAnnotation = firstPage.NextLink;
            }

            return new ODItemCollection { Collection = item.Children, NextLink = item.ChildrenNextLinkAnnotation };
        }
        /// <summary>
        /// Returns a paged children collection for the item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static async Task <ODItemCollection> PagedChildrenCollectionAsync(this ODItem item, ODConnection connection, ChildrenRetrievalOptions options)
        {
            if (item.Children == null)
            {
                var firstPage = await connection.GetChildrenOfItemAsync(item.ItemReference(), options);

                item.Children = firstPage.Collection;
                item.ChildrenNextLinkAnnotation = firstPage.NextLink;
            }

            return(new ODItemCollection {
                Collection = item.Children, NextLink = item.ChildrenNextLinkAnnotation
            });
        }
        /// <summary>
        /// Return a collection of children of an item referenced by item-id
        /// </summary>
        /// <param name="itemReference"></param>
        /// <param name="childrenRetrievalOptions"></param>
        /// <returns></returns>
        public async Task <ODItemCollection> GetChildrenOfItemAsync(ODItemReference itemReference, ChildrenRetrievalOptions childrenRetrievalOptions)
        {
            if (!itemReference.IsValid())
            {
                throw new ArgumentException("ItemReference was invalid. Requires either an ID or Path");
            }

            var queryParams = ODataOptionsToQueryString(childrenRetrievalOptions);
            Uri serviceUri  = UriForItemReference(itemReference, ApiConstants.ChildrenRelationshipName, queryParams);

            return(await DataModelForRequest <ODItemCollection>(serviceUri, ApiConstants.HttpGet));
        }