예제 #1
0
        /// <summary>
        ///     Executes operation.
        /// </summary>
        /// <param name="entity">Entity.</param>
        /// <param name="operation">Operation.</param>
        /// <returns>Result entity.</returns>
        public T Execute(T entity, Func <ITableEntity, TableOperation> operation)
        {
            ITableEntity tableEntity = _entityConverter.GetEntity(entity);
            TableResult  result      = _cloudTable.Execute(operation(tableEntity));

            return(_entityConverter.GetEntity((DynamicTableEntity)result.Result));
        }
예제 #2
0
        /// <summary>
        ///     Executes post processing of retrieved entities.
        /// </summary>
        /// <param name="tableEntities">Table entities.</param>
        /// <param name="translation">translation result.</param>
        /// <returns>Collection of entities.</returns>
        private object GetProcessedResult(IEnumerable <DynamicTableEntity> tableEntities, TranslationResult translation)
        {
            IEnumerable <TEntity> result = tableEntities.Select(q => _entityConverter.GetEntity(q));

            if (translation.PostProcessing == null)
            {
                return(result);
            }

            try
            {
                return(translation.PostProcessing.DynamicInvoke(result.AsQueryable()));
            }
            catch (TargetInvocationException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        ///     Executes batch operations.
        /// </summary>
        /// <param name="entities">List of entities.</param>
        /// <param name="operation">Table operation.</param>
        /// <returns>Result entities.</returns>
        public override IEnumerable <T> ExecuteBatches(IEnumerable <T> entities, Func <ITableEntity, TableOperation> operation)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            IEnumerable <ITableEntity>        tableEntities = entities.Select(p => _entityConverter.GetEntity(p));
            IEnumerable <TableBatchOperation> batches       = _partitioner.GetBatches(tableEntities, operation);

            return(batches.AsParallel().SelectMany(GetEntities));
        }
예제 #4
0
        /// <summary>
        ///     Executes batch operations.
        /// </summary>
        /// <param name="entities">List of entities.</param>
        /// <param name="operation">Table operation.</param>
        /// <returns>Result entities.</returns>
        public override IEnumerable <T> ExecuteBatches(IEnumerable <T> entities, Func <ITableEntity, TableOperation> operation)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            IEnumerable <ITableEntity>        tableEntities = entities.Select(p => _entityConverter.GetEntity(p));
            IEnumerable <TableBatchOperation> batches       = _partitioner.GetBatches(tableEntities, operation);

            // Force evaluation of the execution by calling ToArray()
            return(batches.AsParallel().SelectMany(GetEntities).ToArray());
        }
        /// <summary>
        ///     Executes batch operations.
        /// </summary>
        /// <param name="entities">List of entities.</param>
        /// <param name="operation">Table operation.</param>
        /// <returns>Result entities.</returns>
        public override IEnumerable <T> ExecuteBatches(IEnumerable <T> entities, Func <ITableEntity, TableOperation> operation)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }

            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            IEnumerable <ITableEntity>        tableEntities = entities.Select(p => _entityConverter.GetEntity(p));
            IEnumerable <TableBatchOperation> batches       = _partitioner.GetBatches(tableEntities, operation);

            return(from batch in batches
                   from result in _cloudTable.ExecuteBatch(batch)
                   select _entityConverter.GetEntity((DynamicTableEntity)result.Result));
        }
        /// <summary>
        ///     Executes batch operations.
        /// </summary>
        /// <param name="entities">List of entities.</param>
        /// <param name="operation">Table operation.</param>
        /// <returns>Result entities.</returns>
        public override IEnumerable <T> ExecuteBatches(IEnumerable <T> entities, Func <ITableEntity, TableOperation> operation)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            IEnumerable <ITableEntity>        tableEntities = entities.Select(p => _entityConverter.GetEntity(p));
            IEnumerable <TableBatchOperation> batches       = _partitioner.GetBatches(tableEntities, operation);

            // Force evaluation of the execution by calling ToArray()
            var results = batches.SelectMany(t => _cloudTable.ExecuteBatch(t)).ToArray();

            return(results.Select(t => _entityConverter.GetEntity((DynamicTableEntity)t.Result)));
        }