Update record in Azure table

4 posts, 0 answers
  1. Ove
    Ove  avatar
    4 posts
    Member since:
    Feb 2014

    Posted 09 Jul 2014 Link to this post

    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()}
  2. Ove
    Ove  avatar
    4 posts
    Member since:
    Feb 2014

    Posted 10 Jul 2014 in reply to Ove Link to this post

    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



  3. DevCraft banner
  4. Ove
    Ove  avatar
    4 posts
    Member since:
    Feb 2014

    Posted 10 Jul 2014 in reply to Ove Link to this post

    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
  5. Ves
    Admin
    Ves avatar
    2879 posts

    Posted 14 Jul 2014 Link to this post

    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.

     
Back to Top
DevCraft banner