示例#1
0
 /// <summary>
 /// Removes an edge from the collection.
 /// DELETE /_api/gharial/{graph}/edge/{collection}/{edge}
 /// </summary>
 /// <typeparam name="T">The type of the edge that is returned in
 /// <see cref="DeleteEdgeResponse{T}.Old"/> if requested.</typeparam>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="collectionName">The name of the edge collection the edge belongs to.</param>
 /// <param name="edgeKey">The _key attribute of the edge.</param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual async Task <DeleteEdgeResponse <T> > DeleteEdgeAsync <T>(
     string graphName,
     string collectionName,
     string edgeKey,
     DeleteEdgeQuery query = null,
     CancellationToken cancellationToken = default)
 {
     return(await DeleteRequestAsync(
                $"{ApiRootPath}/{WebUtility.UrlEncode(graphName)}/edge/{WebUtility.UrlEncode(collectionName)}/{WebUtility.UrlEncode(edgeKey)}",
                response => new DeleteEdgeResponse <T>(response), query, cancellationToken));
 }
 /// <summary>
 /// Removes an edge from the collection.
 /// DELETE /_api/gharial/{graph}/edge/{collection}/{edge}
 /// </summary>
 /// <typeparam name="T">The type of the edge that is returned in
 /// <see cref="DeleteEdgeResponse{T}.Old"/> if requested.</typeparam>
 /// <param name="graphName">The name of the graph.</param>
 /// <param name="collectionName">The name of the edge collection the edge belongs to.</param>
 /// <param name="edgeKey">The _key attribute of the edge.</param>
 /// <param name="query"></param>
 /// <returns></returns>
 public virtual Task <DeleteEdgeResponse <T> > DeleteEdgeAsync <T>(
     string graphName,
     string collectionName,
     string edgeKey,
     DeleteEdgeQuery query = null)
 {
     return(DeleteEdgeAsync <T>(
                graphName,
                WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey),
                query));
 }
        /// <summary>
        /// Removes an edge from the collection.
        /// DELETE /_api/gharial/{graph}/edge/{collection}/{edge}
        /// </summary>
        /// <typeparam name="T">The type of the edge that is returned in
        /// <see cref="DeleteEdgeResponse{T}.Old"/> if requested.</typeparam>
        /// <param name="graphName">The name of the graph.</param>
        /// <param name="collectionName">The name of the edge collection the edge belongs to.</param>
        /// <param name="edgeKey">The _key attribute of the edge.</param>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task <DeleteEdgeResponse <T> > DeleteEdgeAsync <T>(
            string graphName,
            string collectionName,
            string edgeKey,
            DeleteEdgeQuery query = null)
        {
            string uri = _graphApiPath + "/" + WebUtility.UrlEncode(graphName) +
                         "/edge/" + WebUtility.UrlEncode(collectionName) + "/" + WebUtility.UrlEncode(edgeKey);

            if (query != null)
            {
                uri += "?" + query.ToQueryString();
            }
            using (var response = await _transport.DeleteAsync(uri))
            {
                if (response.IsSuccessStatusCode)
                {
                    var stream = await response.Content.ReadAsStreamAsync();

                    return(DeserializeJsonFromStream <DeleteEdgeResponse <T> >(stream));
                }
                throw await GetApiErrorException(response);
            }
        }