/// <summary> /// Execute an AQL query, creating a cursor which can be used to page query results. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="query"></param> /// <param name="bindVars"></param> /// <param name="options"></param> /// <param name="count"></param> /// <param name="batchSize"></param> /// <param name="cache"></param> /// <param name="memoryLimit"></param> /// <param name="ttl"></param> /// <param name="transactionId">Optional. The stream transaction Id.</param> /// <returns></returns> public virtual async Task <CursorResponse <T> > PostCursorAsync <T>( string query, Dictionary <string, object> bindVars = null, PostCursorOptions options = null, bool?count = null, long?batchSize = null, bool?cache = null, long?memoryLimit = null, int?ttl = null, string transactionId = null) { var headerProperties = new CursorHeaderProperties(); if (!string.IsNullOrWhiteSpace(transactionId)) { headerProperties.TransactionId = transactionId; } return(await PostCursorAsync <T>( new PostCursorBody { Query = query, BindVars = bindVars, Options = options, Count = count, BatchSize = batchSize, Cache = cache, MemoryLimit = memoryLimit, Ttl = ttl }, headerProperties).ConfigureAwait(false)); }
/// <summary> /// Method to get the header collection. /// </summary> /// <param name="headerProperties">The <see cref="CursorHeaderProperties"/> values.</param> /// <returns><see cref="WebHeaderCollection"/> values.</returns> protected virtual WebHeaderCollection GetHeaderCollection(CursorHeaderProperties headerProperties) { var headerCollection = new WebHeaderCollection(); if (headerProperties != null) { if (!string.IsNullOrWhiteSpace(headerProperties.TransactionId)) { headerCollection.Add(CustomHttpHeaders.StreamTransactionHeader, headerProperties.TransactionId); } } return(headerCollection); }
/// <summary> /// Execute an AQL query, creating a cursor which can be used to page query results. /// </summary> /// <param name="postCursorBody">Object encapsulating options and parameters of the query.</param> /// <param name="headerProperties">Optional. Additional Header properties.</param> /// <returns></returns> public virtual async Task <CursorResponse <T> > PostCursorAsync <T>( PostCursorBody postCursorBody, CursorHeaderProperties headerProperties = null) { var content = GetContent(postCursorBody, new ApiClientSerializationOptions(true, true)); var headerCollection = GetHeaderCollection(headerProperties); using (var response = await _client.PostAsync(_cursorApiPath, content, headerCollection).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) { var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); return(DeserializeJsonFromStream <CursorResponse <T> >(stream)); } throw await GetApiErrorException(response).ConfigureAwait(false); } }