private static RESTCommand <TableQuerySegment <RESULT_TYPE> > QueryImpl <T, RESULT_TYPE>(TableQuery <T> query, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver <RESULT_TYPE> resolver, TableRequestOptions requestOptions) { requestOptions.AssertPolicyIfRequired(); // If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties. if (requestOptions.EncryptionPolicy != null && query.SelectColumns != null && query.SelectColumns.Count() > 0) { query.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails); query.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } UriQueryBuilder builder = query.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); if (token != null) { token.ApplyToUriQueryBuilder(builder); } StorageUri tempUri = NavigationHelper.AppendPathToUri(client.StorageUri, table.Name); RESTCommand <TableQuerySegment <RESULT_TYPE> > queryCmd = new RESTCommand <TableQuerySegment <RESULT_TYPE> >(client.Credentials, tempUri); requestOptions.ApplyToStorageCommand(queryCmd); queryCmd.CommandLocationMode = CommonUtility.GetListingLocationMode(token); queryCmd.RetrieveResponseStream = true; queryCmd.SignRequest = client.AuthenticationHandler.SignRequest; queryCmd.Builder = builder; queryCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; queryCmd.BuildRequestDelegate = (uri, queryBuilder, timeout, useVersionHeader, ctx) => TableOperationHttpWebRequestFactory.BuildRequestForTableQuery(uri, queryBuilder, timeout, useVersionHeader, ctx, requestOptions.PayloadFormat.Value); queryCmd.PreProcessResponse = (cmd, resp, ex, ctx) => HttpResponseParsers.ProcessExpectedStatusCodeNoException(HttpStatusCode.OK, resp != null ? resp.StatusCode : HttpStatusCode.Unused, null /* retVal */, cmd, ex); queryCmd.PostProcessResponse = (cmd, resp, ctx) => { ResultSegment <RESULT_TYPE> resSeg = TableOperationHttpResponseParsers.TableQueryPostProcessGeneric <RESULT_TYPE, T>(cmd.ResponseStream, resolver.Invoke, resp, requestOptions, ctx, client.AccountName); if (resSeg.ContinuationToken != null) { resSeg.ContinuationToken.TargetLocation = cmd.CurrentResult.TargetLocation; } return(new TableQuerySegment <RESULT_TYPE>(resSeg)); }; return(queryCmd); }
private static RESTCommand <TableResult> RetrieveImpl(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions) { requestOptions.AssertPolicyIfRequired(); RESTCommand <TableResult> retrieveCmd = new RESTCommand <TableResult>(client.Credentials, operation.GenerateRequestURI(client.StorageUri, table.Name)); requestOptions.ApplyToStorageCommand(retrieveCmd); TableResult result = new TableResult(); if (operation.SelectColumns != null && operation.SelectColumns.Count > 0) { // If encryption policy is set, then add the encryption metadata column to Select columns in order to be able to decrypt properties. if (requestOptions.EncryptionPolicy != null) { operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionKeyDetails); operation.SelectColumns.Add(Constants.EncryptionConstants.TableEncryptionPropertyDetails); } retrieveCmd.Builder = operation.GenerateQueryBuilder(requestOptions.ProjectSystemProperties); } retrieveCmd.CommandLocationMode = operation.isPrimaryOnlyRetrieve ? CommandLocationMode.PrimaryOnly : CommandLocationMode.PrimaryOrSecondary; retrieveCmd.RetrieveResponseStream = true; retrieveCmd.SignRequest = client.AuthenticationHandler.SignRequest; retrieveCmd.ParseError = ODataErrorHelper.ReadFromStreamUsingODataLib; retrieveCmd.BuildRequestDelegate = (uri, builder, timeout, useVersionHeader, ctx) => TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions, client.AccountName).Item1; retrieveCmd.PreProcessResponse = (cmd, resp, ex, ctx) => TableOperationHttpResponseParsers.TableOperationPreProcess(result, operation, resp, ex); retrieveCmd.PostProcessResponse = (cmd, resp, ctx) => { if (resp.StatusCode == HttpStatusCode.NotFound) { return(result); } result = TableOperationHttpResponseParsers.TableOperationPostProcess(result, operation, cmd, resp, ctx, requestOptions, client.AccountName); return(result); }; return(retrieveCmd); }