当我只有表名开头时,如何获取元数据 - 比如表的属性名称 - 关于Azure表存储的表?这就是我到目前为止所做的:
/// <summary>
/// List the tables in this storage account
/// </summary>
IEnumerable<string> ListAllTables()
{
var storageAccount = GetStorageAccount();
// Create service client for credentialed access to the Table service.
var tableClient = new CloudTableClient(storageAccount.TableEndpoint.ToString(),
storageAccount.Credentials);
return tableClient.ListTables();
}
IEnumerable<string> ListTableMetadata(tableName)
{
// Now, just how can I list all the table metadata?
}
void main()
{
foreach (var tableName in ListAllTables())
{
Console.WriteLine("Table: " + tableName);
// List all the table metadata
Console.WriteLine("Properties: " + ListTableMetadata(tableName));
}
}
答案 0 :(得分:1)
Azure存储表服务不会强制执行表的任何架构。因此,同一个表中的两个实体可能具有不同的属性集。如果您想在不事先知道其属性的情况下查询所有实体,我建议您查看DynamicTableEntity,它将实体的所有属性作为键值对返回。