我构建了一个基于 Azure 的应用程序,我希望在显示实体之前将实体的列规范保存到表存储中。
我怎样才能做到这一点?
最佳答案
试试这个代码:
static void GetAttributeTypes()
{
storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var table = storageAccount.CreateCloudTableClient().GetTableReference("WADLogsTable");
var query = new TableQuery().Take(1);
var result = table.ExecuteQuery(query).ToList();
if (result != null && result.Count > 0)
{
var dynamicTableEntity = result[0];
foreach (var property in dynamicTableEntity.Properties)
{
Console.WriteLine(property.Key + " = " + property.Value.PropertyType);
}
}
}
假设表中的所有实体都具有相同的属性,我所做的就是从表中仅获取一个实体并循环遍历其属性。我使用了存储客户端库2.0.6.1。
关于azure - 表存储获取实体的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19113923/