Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:44:21+00:00 2026-06-18T12:44:21+00:00

With azure tables, if I know an entity’s RowKey and PartitionKey (so I can

  • 0

With azure tables, if I know an entity’s RowKey and PartitionKey (so I can retrieve that entity), how do I edit a particular property value on that entity?

This sounds like a pretty standard operation to do, but the normal way of doing it is something like:

public void UpdateEntity(ITableEntity entity)
{
    TableOperation replaceOperation = TableOperation.Replace(entity);
    table.Execute(replaceOperation);
}

i.e. a whole C# TableEntity object is given as a replacement, rather than an individual property name/value pair.

I want something more like:

public void UpdateEntityProperty<T>(string partitionKey, string rowKey,
                                string propertyName, T newPropertyValue)
{
    TableOperation retrieveOperation = TableOperation.Retrieve(partitionKey, rowKey);
    TableResult retrievedResult = table.Execute(retrieveOperation);
    TableEntity entity = (TableEntity)retrievedResult.Result;

    // This  line, of course, doesn't compile. But you get the idea.
    entity.SetPropertyValue(propertyName, newPropertyValue);

    TableOperation replaceOperation = TableOperation.Replace(entity);
    table.Execute(replaceOperation);
}

My understanding is that behind the scenes, the rows are stored as a set of key-value pairs corresponding to properties on that row, so updating a property’s value should be easy without having to define a whole C# class deriving from TableEntity to do so.

How would I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:44:23+00:00Added an answer on June 18, 2026 at 12:44 pm

    Instead of “Replace” operation, do a “Merge” operation (http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.table.tableoperation.merge). Merge operation will ensure that only the property being modified is changed leaving all other properties unchanged.

    public void UpdateEntityProperty<T>(string partitionKey, string rowKey,
                                        string propertyName, T newPropertyValue)
    {
        TableOperation retrieveOperation = TableOperation.Retrieve(partitionKey, rowKey);
        TableResult retrievedResult = table.Execute(retrieveOperation);
        TableEntity entity = (TableEntity)retrievedResult.Result;
    
        // This  line, of course, doesn't compile. But you get the idea.
        entity.SetPropertyValue(propertyName, newPropertyValue);
    
        TableOperation mergeOperation = TableOperation.Merge(entity);
        table.Execute(mergeOperation);
    }
    

    A more complete example below. Here I first created an employee and then only changed the “MaritalStatus” property of that employee:

    CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
    
    CloudTable table = storageAccount.CreateCloudTableClient().GetTableReference("Employee");
    DynamicTableEntity entity = new DynamicTableEntity()
    {
        PartitionKey = "Employee",
        RowKey = "01",
    };
    Dictionary<string, EntityProperty> properties = new Dictionary<string, EntityProperty>();
    properties.Add("Name", new EntityProperty("John Smith"));
    properties.Add("DOB", new EntityProperty(new DateTime(1971, 1, 1)));
    properties.Add("MaritalStatus", new EntityProperty("Single"));
    entity.Properties = properties;
    
    TableOperation insertOperation = TableOperation.Insert(entity);
    table.Execute(insertOperation);
    
    DynamicTableEntity updatedEntity = new DynamicTableEntity()
    {
        PartitionKey = "Employee",
        RowKey = "01",
        ETag = "*",
    };
    Dictionary<string, EntityProperty> newProperties = new Dictionary<string, EntityProperty>();
    newProperties.Add("MaritalStatus", new EntityProperty("Married"));
    updatedEntity.Properties = newProperties;
    TableOperation mergeOperation = TableOperation.Merge(updatedEntity);
    table.Execute(mergeOperation);
    

    You can also try InsertOrMerge (http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.windowsazure.storage.table.tableoperation.insertormerge.aspx) operation as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that the Azure Storage entities (blobs, tables and queues) have a built-in
Question that is the basis for this one: Alternative to Windows Azure tables out
So I have this app which needs to query entities from the Azure Tables
I've got an azure table record object defined as [DataServiceKey(PartitionKey, RowKey)] public class TableRecord
Is the there the chance to repeat a RowKey in an Azure table that
I want to show 100 items from Azure table, I already know PartitionKey and
So just getting started with Azure tables- haven't played with them before so wanted
Of the following two options... Silverlight app talks directly to Azure Tables Silverlight app
I need to insert an entity in a Azure Table directly from Javascript in
According to this: http://code.google.com/appengine/docs/whatisgoogleappengine.html it seems that GAE only uses Datastore to store data,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.