private static async Task <TableResult> HandleReadAsync(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions options, OperationContext context, CancellationToken cancellationToken)
        {
            try
            {
                if (operation.IsTableEntity)
                {
                    return(EntityHelpers.GetTableResultFromResponse(await DocumentCollectionBaseHelpers.HandleDocumentCollectionRetrieveAsync(operation.GetCosmosTableName(), client.DocumentClient), context));
                }
                RequestOptions requestOptions = GetRequestOptions(operation, options);
                ResourceResponse <Document> resourceResponse = await DocumentEntityCollectionBaseHelpers.HandleEntityRetrieveAsync(table.Name, operation.PartitionKey, operation.RowKey, client.DocumentClient, requestOptions, cancellationToken);

                return(GetTableResultFromResponse(operation, resourceResponse, context, options, operation.SelectColumns, resourceResponse.SessionToken));
            }
            catch (DocumentClientException ex)
            {
                if (ex.StatusCode == HttpStatusCode.NotFound)
                {
                    return(new TableResult
                    {
                        HttpStatusCode = 404,
                        RequestCharge = ex.RequestCharge
                    });
                }
                throw;
            }
        }
        private static async Task <TableResult> HandleInsertAsync(TableOperation operation, CloudTableClient client, CloudTable table, TableRequestOptions options, OperationContext context, CancellationToken cancellationToken)
        {
            if (operation.IsTableEntity)
            {
                DynamicTableEntity tblEntity             = (DynamicTableEntity)operation.Entity;
                string             cosmosTableName       = tblEntity.GetCosmosTableName();
                int?           cosmosTableThroughput     = tblEntity.GetCosmosTableThroughput();
                IndexingPolicy cosmosTableIndexingPolicy = tblEntity.GetCosmosTableIndexingPolicy();
                RequestOptions defaultRequestOptions     = GetDefaultRequestOptions(null, cosmosTableThroughput);
                return(EntityHelpers.GetTableResultFromResponse(await DocumentCollectionBaseHelpers.HandleCollectionFeedInsertAsync(client.DocumentClient, cosmosTableName, cosmosTableIndexingPolicy, defaultRequestOptions, cancellationToken), context));
            }
            Document       documentFromEntity            = EntityHelpers.GetDocumentFromEntity(operation.Entity, context, options);
            RequestOptions requestOptions                = GetRequestOptions(operation, options);
            ResourceResponse <Document> resourceResponse = await DocumentEntityCollectionBaseHelpers.HandleEntityFeedInsertAsync(table.Name, client.DocumentClient, documentFromEntity, requestOptions, cancellationToken);

            return(GetTableResultFromResponse(operation, resourceResponse, context, options, operation.SelectColumns, resourceResponse.SessionToken));
        }