NotSupportedException from EndSaveChanges

Sep 25, 2012 at 11:44 PM

Hello,

I am attempting to create a simple Windows Phone application that directly uses the CloudTableClient and TableServiceContext to add objects into the tables. I have been able to create the table, but I run into some problems when attempting to add an object. I am utterly clueless as what to do here since I don't know where to start the debug. I have been at this for hours and hope someone can help. Here is my piece of code:

public class Contact : TableServiceEntity
{
            public string Name { get; set; }
            public string Address { get; set; }
}

public void Save()
{
            StorageCredentialsAccountAndKey accountAndKey = new StorageCredentialsAccountAndKey("myaccount", "mykey");
            
            ctx = new TableServiceContext("https://myaccount.table.core.windows.net/", accountAndKey);
               
            c = new CloudTableClient(ctx);

            c.CreateTableIfNotExist("table1", null);
            Contact contact = new Contact();
            contact.PartitionKey = "1";
            contact.RowKey = "1";
            contact.Name = "Contact1";
            contact.Address = "Address1";
            ctx.AddObject("Contact", contact);
            ctx.MergeOption = MergeOption.AppendOnly;
            
            ctx.BeginSaveChanges(ar => ctx.EndSaveChanges(ar), null);

            c.DoesTableExist("table1", delegate(CloudOperationResponse<bool> b) { Debug.WriteLine(b.Response); });
}

It's quite a bit of copy-paste from different sources. The last line checks whether the table ahs been created. I have confirmed with this and Azure Storage Explorer that the table is being created.

My problem is that the EndSaveChanges(ar) throws a NotSupportedException.

Furthermore, if I was to get this to work and it saved it to the database, is TryGetEntity the way to go about retrieving them?

The biggest problems for me are that the interfaces are quite similar to those in VS2012 toolkit or the Windows version of things, which makes it really difficult to Google. Furthermore, most examples concentrate on using Silverlight and services while I want to have direct access to the tables with my app.

Thanks in advance!