从azure表中检索单个实体

时间:2012-10-06 12:30:22

标签: azure azure-storage azure-table-storage

我正在尝试使用Patitionkey和Rowkey从azure表中获取单个实体。我在这里面临的问题是,当没有实体匹配Partitionkey或Rowkey时,它不会返回null。

MyRecordsTable specificEntity =
            (from e in serviceContext.CreateQuery<MyRecordsTable >("MyRecordsTable ")
             where e.PartitionKey == pkey && e.RowKey == rkey
             select e).FirstOrDefault();

我引用了以下链接,它表示如果没有匹配,则应返回null。但我收到异常(An error occurred while processing this request.)内部异常为No resource found.

http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services/#header-11

1 个答案:

答案 0 :(得分:3)

这是任何REST驱动的数据源的默认行为。如果未找到,则返回HTTP 404错误。如果您想要获取NULL,则必须使用IgnoreResourceNotFoundException属性并将其设置为true。

相关问题