Kiran Madipally
Kiran Madipally

Reputation: 847

Azure Table Storage query for records based on property that may not exist for all records

I am using Azure Table Storage for my service and I am trying to introduce a soft delete feature to it. I would be adding a property IsMarkedForDeletion to entries that are marked for deletion. When I query, I need only the entries that are not marked for deletion. In fields which are not deleted, IsMarkedForDeletion will not even exist.

I have tried the following:

<...query...> and (IsMarkedForDeletion ne true)
<...query...> and (IsMarkedForDeletion eq false)
<...query...> and (not (IsMarkedForDeletion ne false))
<...query...> and (not (IsMarkedForDeletion eq true))

<...query...> and (not (IsMarkedForDeletion eq NULL)) => returns 501 Not Implemented

None of them showed the entries that did not have the IsMarkedForDeletion property in them.

What do I do so that I get the records that do not have IsMarkedForDeletion as well as the records were IsMarkedForDeletion property exists, but is false?

I have thought about scrubbing the database and adding the IsMarkedForDeletion to all the records, or filtering the results myself after the query is executed, but I would like to do it in the query itself so that it is easy for me while creating segmented requests and paging the results.

Upvotes: 2

Views: 1496

Answers (1)

alek kowalczyk
alek kowalczyk

Reputation: 4936

I do not think that is possible, you could try to check if the field is equal to null, I don't know if that would solve your issue. But generally Table Storage has no schema, and is not intended to be used for querying fields other than the partition key and row key. I personally think you would get the result faster by getting all the result for given PK+RK and filtering them out later out, than leaving it to table storage to filter on a field that is not in the PK+RK pair.

Upvotes: 1

Related Questions