Update Record in Windows Azure Table storage

As told in my previous Blogpost I kept a list of the Blob name and the LastModifiedUtc. To make this solution usable for more then one instances I stored this list in a Windows Azure storage table.

So if I copied a Blob with a changed LastModifiedUtc, I had to update my list too.

Adding a new record to the Table storage was rather simple.

this.context.AddObject(

               BlobCheckListContext.BlobCheckListTable, 

               newItem

             );

this.context.SaveChanges();

But for updating you need to do something little extra. Btw this also goes for a deletion.

this.context.AttachTo(

               BlobCheckListContext.BlobCheckListTable, 

               updatedItem, 

               "*"

             );
this.context.UpdateObject(updatedItem);
this.context.SaveChangesWithRetries(

               SaveChangesOptions.ReplaceOnUpdate

             );

So before updating of deleting you need to Attach to the record and than excute the UpdateObject.

Leave a Reply