/// <summary> /// Sends a request for a N1QL query to the server. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <param name="cancellationToken">Token which can cancel the query.</param> /// <returns></returns> async Task <IQueryResult <T> > IServer.SendAsync <T>(IQueryRequest queryRequest, CancellationToken cancellationToken) { IQueryResult <T> result; if (_isDown) { result = HandleNodeUnavailable <T>(queryRequest); } else { try { queryRequest.BaseUri(CachedQueryBaseUri); if (queryRequest.IsStreaming) { result = await _streamingQueryClient.QueryAsync <T>(queryRequest, cancellationToken).ContinueOnAnyContext(); } else { result = await QueryClient.QueryAsync <T>(queryRequest, cancellationToken).ContinueOnAnyContext(); } } catch (Exception e) { result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false }; } } return(result); }
public IQueryResult <IQueryPlan> Prepare(IQueryRequest toPrepare) { var uri = new Uri(GetBaseQueryUri()); toPrepare.BaseUri(uri); return(QueryClient.Prepare(toPrepare)); }
/// <summary> /// Sends a request for a N1QL query to the server asynchronously. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns> /// An <see cref="Task{IQueryResult}" /> object representing the asynchronous operation. /// </returns> IQueryResult <T> IServer.Send <T>(IQueryRequest queryRequest) { IQueryResult <T> result; if (_isDown) { result = HandleNodeUnavailable <T>(queryRequest); } else { try { queryRequest.BaseUri(CachedQueryBaseUri); // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (queryRequest.IsStreaming) { result = _streamingQueryClient.Query <T>(queryRequest); } else { result = QueryClient.Query <T>(queryRequest); } } catch (Exception e) { result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false, }; } } return(result); }
/// <summary> /// Sends a request for a N1QL query to the server. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns></returns> async Task <IQueryResult <T> > IServer.SendAsync <T>(IQueryRequest queryRequest) { IQueryResult <T> result; if (_isDown) { result = HandleNodeUnavailable <T>(queryRequest); } else { try { queryRequest.BaseUri(CachedQueryBaseUri); result = await QueryClient.QueryAsync <T>(queryRequest).ContinueOnAnyContext(); } catch (Exception e) { MarkDead(); result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false }; } } return(result); }
/// <summary> /// Sends a request for a N1QL query to the server asynchronously. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns> /// An <see cref="Task{IQueryResult}" /> object representing the asynchronous operation. /// </returns> IQueryResult <T> IServer.Send <T>(IQueryRequest queryRequest) { IQueryResult <T> result; if (_isDown) { result = HandleNodeUnavailable <T>(queryRequest); } else { try { queryRequest.BaseUri(CachedQueryBaseUri); result = QueryClient.Query <T>(queryRequest); } catch (Exception e) { MarkDead(); result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false, }; } } return(result); }
/// <summary> /// Sends a request for a N1QL query to the server. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns></returns> Task <IQueryResult <T> > IServer.SendAsync <T>(IQueryRequest queryRequest) { if (queryRequest.GetBaseUri() == null) { var uri = new Uri(GetBaseQueryUri()); queryRequest.BaseUri(uri); } return(QueryClient.QueryAsync <T>(queryRequest)); }
/// <summary> /// Sends a request for a N1QL query to the server asynchronously. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns> /// An <see cref="Task{IQueryResult}" /> object representing the asynchronous operation. /// </returns> IQueryResult <T> IServer.Send <T>(IQueryRequest queryRequest) { IQueryResult <T> result; try { queryRequest.BaseUri(CachedQueryBaseUri); result = QueryClient.Query <T>(queryRequest); } catch (Exception e) { result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false, }; } return(result); }
/// <summary> /// Sends a request for a N1QL query to the server asynchronously. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns> /// An <see cref="Task{IQueryResult}" /> object representing the asynchronous operation. /// </returns> IQueryResult <T> IServer.Send <T>(IQueryRequest queryRequest) { IQueryResult <T> result; try { if (queryRequest.GetBaseUri() == null) { var uri = new Uri(GetBaseQueryUri()); queryRequest.BaseUri(uri); } result = QueryClient.Query <T>(queryRequest); } catch (Exception e) { result = new QueryResult <T> { Exception = e, Message = e.Message, Success = false, }; } return(result); }
public IQueryResult <QueryPlan> Prepare(IQueryRequest toPrepare) { toPrepare.BaseUri(CachedQueryBaseUri); return(QueryClient.Prepare(toPrepare)); }
/// <summary> /// Sends a request for a N1QL query to the server. /// </summary> /// <typeparam name="T">The <see cref="Type" /> T of the body for each row (or document) result.</typeparam> /// <param name="queryRequest">A <see cref="IQueryRequest" /> object.</param> /// <returns></returns> Task <IQueryResult <T> > IServer.SendAsync <T>(IQueryRequest queryRequest) { queryRequest.BaseUri(CachedQueryBaseUri); return(QueryClient.QueryAsync <T>(queryRequest)); }