/// <summary> /// This request is used to execute a batch of updates against a PreparedStatement. /// </summary> public async Task <ExecuteBatchResponse> ExecuteBatchRequestAsync(string connectionId, uint statementId, pbc::RepeatedField <UpdateBatch> updates) { ExecuteBatchRequest req = new ExecuteBatchRequest { ConnectionId = connectionId, StatementId = statementId }; req.Updates.AddRange(updates); WireMessage msg = new WireMessage { Name = Constants.WireMessagePrefix + "ExecuteBatchRequest", WrappedMessage = req.ToByteString() }; using (Response webResponse = await PostRequestAsync(msg.ToByteArray())) { if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK) { WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream()); ErrorResponse res = ErrorResponse.Parser.ParseFrom(output.WrappedMessage); throw new WebException( string.Format( "ExecuteBatchRequestAsync failed! connectionId: {0}, Response code was: {1}, Response body was: {2}", connectionId, webResponse.WebResponse.StatusCode, res.ToString())); } else { WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream()); ExecuteBatchResponse res = ExecuteBatchResponse.Parser.ParseFrom(output.WrappedMessage); return(res); } } }
/// <summary> /// This request is used to execute a batch of updates against a PreparedStatement. /// </summary> public async Task<ExecuteBatchResponse> ExecuteBatchRequestAsync(string connectionId, uint statementId, pbc::RepeatedField<UpdateBatch> updates, RequestOptions options) { ExecuteBatchRequest req = new ExecuteBatchRequest { ConnectionId = connectionId, StatementId = statementId, Updates = updates }; WireMessage msg = new WireMessage { Name = Constants.WireMessagePrefix + "ExecuteBatchRequest", WrappedMessage = req.ToByteString() }; using (Response webResponse = await PostRequestAsync(msg.ToByteArray(), options)) { if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK) { WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream()); ErrorResponse res = ErrorResponse.Parser.ParseFrom(output.WrappedMessage); throw new WebException( string.Format( "ExecuteBatchRequestAsync failed! connectionId: {0}, Response code was: {1}, Response body was: {2}", connectionId, webResponse.WebResponse.StatusCode, res.ToString())); } else { WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream()); ExecuteBatchResponse res = ExecuteBatchResponse.Parser.ParseFrom(output.WrappedMessage); return res; } } }