简体   繁体   English

使用 Azure.Data.Tables.TableClient 检查 Azure 存储表中是否存在一行

[英]Check if a row exists in Azure Storage Table using the Azure.Data.Tables.TableClient

I'm using Azure.Data.Tables.TableClient (also looked at Azure.Data.Tables.TableServiceClient ).我正在使用Azure.Data.Tables.TableClient (也查看了Azure.Data.Tables.TableServiceClient )。

I want to check if a record exists in the Azure Table given a specific Partition Key and Row Key.我想检查给定特定分区键和行键的 Azure 表中是否存在记录。 Calling the TableClient.GetEntity<T> throws an exception if it gets 404 from the server rather than returning null.如果从服务器获取 404 而不是返回 null,则调用TableClient.GetEntity<T>会引发异常。

I've searched on SO and there is one solution available but it uses the older CloudTable .我搜索过 SO 并且有一个可用的解决方案,但它使用旧的CloudTable

I've tried looking at the TableServiceClient options but so far haven't had any success finding a good solution that doesnt require catching the exception.我已经尝试查看TableServiceClient选项,但到目前为止还没有成功找到不需要捕获异常的好的解决方案。

You can probably use Query and specify your query as PartitionKey eq 'partition-key-value' and RowKey eq 'row-key-value' .您可能可以使用Query并将查询指定为PartitionKey eq 'partition-key-value' and RowKey eq 'row-key-value'

If the entity does not exist, you will receive an empty array back instead of error.如果该实体不存在,您将收到一个空数组而不是错误。 If the entity exists, you will receive an array with just 1 entity.如果该实体存在,您将收到一个只有 1 个实体的数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Azure.Data.Tables TableClient 依赖注入多表? - How to use Azure.Data.Tables TableClient with dependency injection multiple tables? Azure 控制台应用程序中的 tableclient 使用交互式身份验证 - Azure tableclient in console app using interactive authentication Python:检查Azure队列存储是否存在 - Python: Check if Azure queue storage exists PowerShell:使用 PS 从 Azure 表存储中获取实体(行)以填充另一个表 - PowerShell: Using PS to get entities (row) from an Azure Table Storage to populate another table 如何检查管道是否存在于 Azure 数据工厂中? - How to check if the pipeline exists in the Azure Data Factory? 如何使用 RBAC 连接到 Azure 表存储 - How to connect to Azure Table Storage using RBAC 如何使用 Azure 数据工厂服务的 Web 活动将实体插入 Azure 存储表 - How to insert an entity into Azure Storage table using Web Activity of Azure Data Factory service Azure 存储表最大分区和最大行键 - Azure storage table max partition and max row key 无法使用 Azure CLI 查询 Azure 表存储 - Unable to query Azure Table Storage using Azure CLI 如何查看Azure Synapse中物化视图数据存储和维护成本? - How to check materialized view data storage and maintenance cost in Azure Synapse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM