0

I have to write a code in C# to edit table entity. I have got this far but ".Edit" doesn't exist and it doesn't edit when I run and test. Would you know what is wrong there, please?

protected void btnEdit_Click(object sender, EventArgs e)
    {
        string rowKey = GetRowKeyFirstSelectedMessage();

        CloudTable myMessagesCloudTable = GetMessagesCloudTable();

        TableOperation retrieveOperation = TableOperation.Retrieve<MessageEntity>("P1", rowKey);

        TableResult retrieveResult = myMessagesCloudTable.Execute(retrieveOperation);

        MessageEntity editMessage = (MessageEntity)retrieveResult.Result;
                 txtAuthor.Text = editMessage.Author;
                 txtMessage.Text = editMessage.MessageText;


        TableOperation editOperation = TableOperation.Edit(editMessage);
        myMessagesCloudTable.Execute(editOperation);

        dataListMessages.DataBind();
    }    

1 Answer 1

1

There is no Edit method. Instead use TableOperation.Replace. See https://msdn.microsoft.com/en-us/library/azure/microsoft.windowsazure.storage.table.tableoperation.replace.aspx

There is also TableOperation.InsertOrReplace that will create a record if it does not exist and updates a record if it does.

More details can be found here: https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-tables/#replace-an-entity

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.