Ejemplo n.º 1
0
        private async Task <BatchResult> PutBatch(IEnumerable <T> entities, BatchResult result)
        {
            #region Preconditions

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

            #endregion

            // Up to 25 items put or delete operations, with the request size not exceeding 1 MB.

            var putRequests = entities
                              .Select(e => (ItemRequest) new PutRequest(AttributeCollection.FromObject(e, metadata)))
                              .ToList();

            var tableBatch = new TableRequests(tableName, putRequests);

            await BatchWriteItem(tableBatch, result).ConfigureAwait(false);

            result.BatchCount++;

            return(result);
        }
Ejemplo n.º 2
0
        // Conditional put
        public Task <PutItemResult> PutAsync(T entity, params Expression[] conditions)
        {
            var request = new PutItemRequest(tableName, AttributeCollection.FromObject(entity, metadata));

            if (conditions != null)
            {
                request.SetConditions(conditions);
            }

            return(client.PutItemWithRetryPolicy(request, retryPolicy));
        }
Ejemplo n.º 3
0
        public Task <PutItemResult> PutAsync(T entity)
        {
            var request = new PutItemRequest(tableName, AttributeCollection.FromObject(entity, metadata));

            return(client.PutItemWithRetryPolicy(request, retryPolicy));
        }