问题
I'm trying to dynamically add properties to Azure Table Storage using the ReadingEntity and WritingEntity events, as described here: How to add new properties to an entity saved in Azure Table Storage?.
The purpose is to save a List property on my poco into table storage. To accomplish this, every time I need to add a new item to the list for an entity, I'm getting that entity out of Table Storage, counting the number of properties with a certain name that the entity has, and then adding another one with the same name and an incremented index at the end - for example, if an entity has properties Friend1, Friend2, and Friend3, I will add Friend4.
The problem I'm hitting is that when I add a property to 1 entity, it seems to add it to all entities in the table (or maybe the partition - I haven't checked). So if I add Friend1 to Entity1, and then add a Friend property to Entity2, I'm expecting to add Entity2.Friend1. Instead, Friend1 seems to already exist on Entity2, with a NULL value. So the code that adds the property sees Friend1 already there, and adds a Friend2 property to Entity2. As if this were a relational database and I'm creating a column in the schema. Obviously this totally destroys my plans for how to store this info ...
Is this how it's supposed to work?? I was working with the understanding that properties could be unique to each entity.
Thanks!
回答1:
Gaurav and smarx were right - the problem goes away when using the Table Storage Service and not the local storage service emulator.
来源:https://stackoverflow.com/questions/11813376/adding-property-to-entity-in-azure-table-storage-seems-to-add-null-property-to-a