Murilo Maciel Curti
Murilo Maciel Curti

Reputation: 3131

How to store different types with the same partitionkey in the same table on windows azure table?

I have two related entities.

Fruits.Apple Cars.Bmw

Those entities belongs to the same user and I want to use the userId as the partitionKey for both entities.

I am storing them in the same partition but when I use CreateQuery passing the partitionKey the query returns all entities with that partition and no only apples.

This is throwing an exception:

"The current value 'Fruits.Apple' type is not compatible with the expected 'Cars.Bmw' type."

Is there a whey to filter by type to avoid this kind of error?

Thank you,

Murilo

Upvotes: 0

Views: 77

Answers (1)

hocho
hocho

Reputation: 1749

Adding a fixed length 'Type' indicator as a Row Key prefix, and filtering on the PartitionKey and the RowKey prefix as a range (>= prefix && < prefix+) will allow you to store multiple entities in one table and use the same partition key.

Upvotes: 2

Related Questions