且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何向保存在Azure表存储中的实体添加新属性?

更新时间:2023-12-01 08:20:34

我假设您正在使用.NET,因为您提到了映射到表中实体的类.表存储本身没有架构,因此这是一个完全不存在的问题.

I'm assuming you're using .NET, because you mentioned classes mapping to entities in tables. Table storage itself has no schema, so this is a complete non-issue.

在没有模式的情况下使用WCF数据服务客户端库(位于Microsoft.WindowsAzure.Storage下).搜索与表存储有关的ReadingEntityWritingEntity,您可能会找到所需的内容.本质上,您需要挂钩这些事件并解析(或注入)所需的额外属性.人们通常通过创建一个字典属性来处理这些额外"属性,然后在发生这些事件时对其进行读写来实现此目的.

Using the WCF Data Services client library (what's underneath Microsoft.WindowsAzure.Storage) without a schema is a bit tricky. Search for ReadingEntity and WritingEntity relating to table storage, and you'll probably find what you need. Essentially, you need to hook these events and parse (or inject) the extra properties you want. People usually do this by creating a dictionary property to handle those "extra" properties and then read and write them when those events fire.

您还可以签出 http://www.lucifure.com/,该客户端库是我没有经验.我相信它也解决了这一局限性:通过字典进行动态隐藏,因此您不必将每个表属性都映射到类成员."

You might also check out http://www.lucifure.com/, an alternative client library that I have no experience with. I believe it addresses this limitation too: "Dynamic stashing via a dictionary, so you do not have to map every table property to a class member."