private void MovePageRecursively(Models.Site site, string pageFullName, string newParent, TableServiceContext serviceContext) { var oldPage = Get(new Page(site, pageFullName)); var entity = PageEntityHelper.ToPageEntity(oldPage); if (!string.IsNullOrEmpty(newParent)) { var newPage = new Page(new Page(site, newParent), oldPage.Name); entity.FullName = newPage.FullName; entity.ParentPage = newPage.Parent.FullName; } else { entity.FullName = oldPage.Name; entity.ParentPage = ""; } foreach (var item in ChildPages(oldPage)) { MovePageRecursively(site, item.FullName, entity.FullName, serviceContext); } serviceContext.AddObject(PageTable, entity); var oldEntity = PageEntityHelper.ToPageEntity(oldPage); serviceContext.AttachTo(PageTable, oldEntity, "*"); serviceContext.DeleteObject(oldEntity); }
public void SaveFriendLikes() { // Persist friend likes to Table Storage var context = new TableServiceContext(tableClient.BaseUri.ToString(), tableClient.Credentials); // Using the Upsert pattern in the August 2011 API / November 2011 SDK (1.6) var n = 0; foreach (var k in FriendLikes.Keys) { context.AttachTo(FRIEND_LIKES_TABLE, FriendLikes[k]); context.UpdateObject(FriendLikes[k]); if (n++ % 100 == 0) { context.SaveChangesWithRetries(SaveChangesOptions.Batch|SaveChangesOptions.ReplaceOnUpdate); } } // Create the pre-calculated JSON Blob var blob = blobContainer.GetBlobReference(UserId); var likes = GetOrderedFriendLikes(); var json = JsonConvert.SerializeObject(likes); blob.UploadText("dataCallback(" + json + ")"); }