Esempio n. 1
0
        public void Add(Release release)
        {
            var json = JsonConvert.SerializeObject(release);
            var key = release.Version.ToString();
            var insertOperation = TableOperation.Insert(new ReleaseEntity(json, key));

            // Execute the insert operation.
            _table.Execute(insertOperation);
        }
Esempio n. 2
0
        public void Save(Release release)
        {
            // Create a retrieve operation that takes a Release entity.
            var partitionKey = release.Version.ToString();
            var retrieveOperation = TableOperation.Retrieve<ReleaseEntity>(partitionKey, partitionKey);

            // Execute the operation.
            var retrievedResult = _table.Execute(retrieveOperation);

            // Assign the result to a ReleaseEntity object.
            var updateEntity = (ReleaseEntity) retrievedResult.Result;

            if (updateEntity == null)
                throw new KeyNotFoundException("Not found");

            updateEntity.Json = JsonConvert.SerializeObject(release);

            // Create the InsertOrReplace TableOperation.
            var updateOperation = TableOperation.Replace(updateEntity);

            // Execute the operation.
            _table.Execute(updateOperation);
        }