reggieboyYEAH
reggieboyYEAH

Reputation: 910

Query azure table to return only specific entities

I have an azure table that contains 2 different entities

These 2 entity have the same partition key, it is intentional by design so these entities are

stored in one partition.

Row key is of course unique.

Is it possible to query only a specific entity by partition key?

or do i have to manualy create a property as an identifier for each entity in the same azure table?

basically the shape of my table is

Partition Key| Row Key  |Entity Type |
====================================
1            |  X       | Entity A
1            |  Y       | Entity B
1            |  Z       | Entity B

I only want to retrieve for Entity B using the Partition Key 1

Upvotes: 0

Views: 586

Answers (2)

hocho
hocho

Reputation: 1749

To query a specific entity you need to supply both the partition and the row key.

If you query only on the partition key, you get all rows with that partition key.

In your example above, querying using the partition key and 'Entity Type' will be less efficient than querying on the partition key and the row key. If the partition is large, the query can be quite slow since a partition scan will be needed.

Upvotes: 1

Heath
Heath

Reputation: 3311

Specify both the partition key and the row key to retrieve a single entity. See http://www.windowsazure.com/en-us/documentation/articles/storage-dotnet-how-to-use-table-storage-20/#retrieve-single-entity for example code.

Upvotes: 1

Related Questions