示例#1
0
        /// <summary>
        /// Writes a batch (TableBatchOperation) to the Table
        /// </summary>
        protected virtual IList <XTableResult> WriteNextBatch(string partitionKey, IList <T> entities, Action onPreExecuteBatch)
        {
            return(RetryPolicy.ExecuteAction(() =>
            {
                List <XTableResult> results;
                TableBatchOperation batchOperation = PrepareNextBatchOperation(entities, partitionKey, out results);

                onPreExecuteBatch();

                // Execute Batch Operation
                if (batchOperation.Count > 0)
                {
                    var tresults = Table.ExecuteBatch(batchOperation);
                    for (int i = 0, nexti = 0; i < tresults.Count; ++i)
                    {
                        while (results[nexti].Discarded)
                        {
                            ++nexti;
                        }
                        results[nexti++].TableResult = tresults[i];
                    }
                }

                // Operation succeedeed
                return results;
            }));
        }