public IEnumerable <TOut> ExecuteQuery <TOut>(string cypherQuery) { var request = CypherQueryRequest.Create(cypherQuery); var srequest = _serializer.Serialize(request); Logger.Current.Log("Executing: " + srequest, LogLevel.Info); var responseTask = _webClient.PostAsync(_transactionUri, srequest); responseTask.Wait(); var readTask = responseTask.Result.Content.ReadAsStringAsync(); readTask.Wait(); var response = readTask.Result; Logger.Current.Log("Response: " + response, LogLevel.Info); var cypherResponse = _serializer.Deserialize <CypherResponse <TOut> >(response); if (cypherResponse.Errors.Any()) { throw new CypherResponseException(cypherResponse.Errors.Select(e => e.Message).ToArray()); } if (!_isInitialized) { _transactionUri = cypherResponse.Commit.Substring(0, cypherResponse.Commit.Length - ("/commit").Length); _isInitialized = true; } return(cypherResponse.Results ?? Enumerable.Empty <TOut>()); }
public IEnumerable <TOut> ExecuteQuery <TOut>(string cypherQuery) { var request = CypherQueryRequest.Create(cypherQuery); var srequest = _serializer.Serialize(request); Logger.Current.Log("Executing: " + srequest, LogLevel.Info); var responseTask = _webClient.PostAsync(_baseUri, srequest); var response = responseTask.Result.Content.ReadAsStringAsync().Result; Logger.Current.Log("Response: " + response, LogLevel.Info); var cypherResponse = _serializer.Deserialize <CypherResponse <TOut> >(response); if (cypherResponse.Errors.Any()) { throw new CypherResponseException(cypherResponse.Errors); } return(cypherResponse.Results); }
public IEnumerable <TOut> ExecuteQuery <TOut>(string cypherQuery) { var request = CypherQueryRequest.Create(cypherQuery); var srequest = _serializer.Serialize(request); Logger.Current.Log("Executing: " + srequest, LogLevel.Info); var responseTask = _webClient.PostAsync(_baseUri, _username, _password, srequest); responseTask.Wait(); var readTask = responseTask.Result.Content.ReadAsStringAsync(); readTask.Wait(); var response = readTask.Result; Logger.Current.Log("Response: " + response, LogLevel.Info); var cypherResponse = _serializer.Deserialize <CypherResponse <TOut> >(response); if (cypherResponse.Errors.Any()) { throw new CypherResponseException(cypherResponse.Errors.Select(e => e.Message).ToArray()); } return(cypherResponse.Results ?? Enumerable.Empty <TOut>()); }