我的数据读取代码(当前使用 Microsoft.Azure.Cosmos.Table)调用一个简单的方法来检查表是否存在;然后据此做出决策。 (如果表不存在,我不想创建它;我只是在这里阅读。)
如何在我们现在敦促迁移到的 Azure.Data.Tables 中执行相同的操作?
最佳答案
根据christothes的建议:
- 您可以使用
TableServiceClient.Query
方法。
a simple method to check to see if a table exists or not; it then make decisions based on that. (I don't want to create the table if it doesn't exist; I'm just reading here.)
bool exists = false;
await foreach(var tbl in service.QueryAsync(t => t.Name == "mytable"))
{
exists = true;
}
引用文献:Migration guide from Microsoft.Azure.Cosmos.Table to Azure.Data.Tables和 Tables migration guide should provide more context on the omission of the Exists method
关于.net - 如何检查 Azure.Data.Tables 中是否存在表(v 12.5.0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72014909/