Quantcast
Channel: Marcel Meijer Blog » Storage
Viewing all articles
Browse latest Browse all 13

Update Record in Windows Azure Table storage

$
0
0

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.


Viewing all articles
Browse latest Browse all 13

Trending Articles