Beispiel #1
0
        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           = StorageExtendedErrorInformation.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);
        }
Beispiel #2
0
 public virtual Task <TableQuerySegment <TElement> > ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return(AsyncExtensions.TaskFromApm(this.BeginExecuteSegmented, this.EndExecuteSegmented, currentToken, requestOptions, operationContext, cancellationToken));
 }
Beispiel #3
0
        internal ICancellableAsyncResult BeginExecuteQuerySegmentedInternal <TResult>(TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver <TResult> resolver, TableRequestOptions requestOptions, OperationContext operationContext, AsyncCallback callback, object state)
        {
            CommonUtility.AssertNotNullOrEmpty("tableName", table.Name);
            CommonUtility.AssertNotNull("resolver", resolver);

            TableRequestOptions modifiedOptions = TableRequestOptions.ApplyDefaults(requestOptions, client);

            operationContext = operationContext ?? new OperationContext();

            return(Executor.BeginExecuteAsync(
                       QueryImpl(this, token, client, table, resolver, modifiedOptions),
                       modifiedOptions.RetryPolicy,
                       operationContext,
                       callback,
                       state));
        }
Beispiel #4
0
 public virtual Task <TableQuerySegment <TElement> > ExecuteSegmentedAsync(TableContinuationToken currentToken, TableRequestOptions requestOptions, OperationContext operationContext)
 {
     return(this.ExecuteSegmentedAsync(currentToken, requestOptions, operationContext, CancellationToken.None));
 }
Beispiel #5
0
 public virtual Task <TableQuerySegment <TElement> > ExecuteSegmentedAsync(TableContinuationToken currentToken, CancellationToken cancellationToken)
 {
     return(AsyncExtensions.TaskFromApm(this.BeginExecuteSegmented, this.EndExecuteSegmented, currentToken, cancellationToken));
 }
Beispiel #6
0
 public virtual Task <TableQuerySegment <TElement> > ExecuteSegmentedAsync(TableContinuationToken currentToken)
 {
     return(this.ExecuteSegmentedAsync(currentToken, CancellationToken.None));
 }
Beispiel #7
0
 public virtual ICancellableAsyncResult BeginExecuteSegmented(TableContinuationToken currentToken, AsyncCallback callback, object state)
 {
     return(this.BeginExecuteSegmented(currentToken, null /* RequestOptions */, null /* OperationContext */, callback, state));
 }
 internal TableQuerySegment(ResultSegment <TElement> resSeg)
     : this(resSeg.Results)
 {
     this.continuationToken = (TableContinuationToken)resSeg.ContinuationToken;
 }