This is a migrated thread and some comments may be shown as answers.

Update record in Azure table

3 Answers 92 Views
CloudDataSync
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ove
Top achievements
Rank 1
Ove asked on 10 Jul 2014, 03:54 AM
Hi
I have an existing aplication using Azure and now I want to try to implement CloudDataAync.
I got so far that when I insert record data gets inserted in the cloud and the local db.
I do this:
await item.SynchronizeAsync();
await Context.SynchronizeAsync();

But when I want to update doing this:
var existingWalletT = App.ViewModel.WalletVM.Wallet3.Where(X => X.Id == existingWallet.Id).Select(x => x).FirstOrDefault();
existingWalletT.Id = null;
existingWalletT.Name = tbName.Text;
existingWalletT.pin = tbPin.Text;
existingWalletT.Icon = ((System.Windows.Media.Imaging.BitmapImage)(walletImmage.Source)).UriSource.ToString();
await existingWalletT.SynchronizeAsync();

I get the error below
What am I doing wrong?
 I have manually added the column synchronizationid and populated it with the same value as in the Id column hence my table already contained data when I started to add CloudDataSync





Telerik.Windows.Cloud.SynchronizationException: The id parameter type 'System.Guid' is invalid for looking up items of type 'Wallet'. ---> System.InvalidOperationException: The id parameter type 'System.Guid' is invalid for looking up items of type 'Wallet'.
   at Microsoft.WindowsAzure.MobileServices.MobileServiceSerializer.EnsureValidIdForType[T](Object id)
   at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<LookupAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.WindowsAzure.MobileServices.MobileServiceTable`1.<LookupAsync>d__1e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Telerik.Windows.Cloud.Azure.AzureCloudService`1.<GetItemAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Telerik.Windows.Cloud.SynchronizationContext`1.<Telerik.Windows.Cloud.ISynchronizationContext.SynchronizeItemAsync>d__2.MoveNext()
   --- End of inner exception stack trace ---
   at Telerik.Windows.Cloud.SynchronizationContext`1.<Telerik.Windows.Cloud.ISynchronizationContext.SynchronizeItemAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Telerik.Windows.Cloud.Azure.AzureSynchronizableCloudItem.<SynchronizeAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at WalletViewModel.<UpdateWalletInTable>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at AddWalletPage.<SaveButton_Click>d__33.MoveNext()}

3 Answers, 1 is accepted

Sort by
0
Ove
Top achievements
Rank 1
answered on 10 Jul 2014, 11:38 AM
Today I also tried the sample from telerik with the person table. I can add records but when I try to update using this I get an error:
​ var p = MainViewModel.Instance.Persons.Select(x => x).FirstOrDefault();
// Synchronize the newly created person
p.Name = name;
p.Age = age;
await p.SynchronizeAsync();
NavigationService.GoBack();

Error:
System.InvalidOperationException was unhandled
Message: An exception of type 'System.InvalidOperationException' occurred in Microsoft.WindowsAzure.Mobile.DLL and wasn't handled before a managed/native boundary



0
Ove
Top achievements
Rank 1
answered on 10 Jul 2014, 11:56 AM
I discovered that this work:
​var p = MainViewModel.Instance.Persons.Select(x => x).FirstOrDefault();
// Synchronize the newly created person
p.Name = name;
p.Age = age;
await p.UpdateAsync();
await MainViewModel.Instance.Context.SynchronizeAsync();
NavigationService.GoBack();

But according to the documentation I should be able to use the code I wrote in my previous post
0
Ves
Telerik team
answered on 14 Jul 2014, 03:27 PM
Hi Ove,

Can you please make sure that your Azure table scheme includes id field of type string? If this is the case, please make sure you use the latest release of Telerik UI for Windows Phone (Q2 2014). Finally, if this is also the case, you can open a private support ticket and send your application, so that we can investigate it and get back to you with our findings.

Best regards,
Ves
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
CloudDataSync
Asked by
Ove
Top achievements
Rank 1
Answers by
Ove
Top achievements
Rank 1
Ves
Telerik team
Share this question
or