azureazure-storageazure-table-storageazure-tablequery

How to use Microsoft.WindowsAzure.Storage.Table 's TableOperators.Not operator


I am using Microsoft.WindowsAzure.Storage.Table's TableOperators to generate table queries and combining clauses using TableQuery.CombineFilters. But I do not see a way to use 'TableOperators.Not' to take negation of a clause. How can that be done?


Solution

  • First of all, these 2 operators like TableOperators.And and TableOperators.Or, which can be used to concatenate 2 filters. So these 2 operators can be used within TableQuery.CombineFilters.

    But for TableOperators.Not, which is just used for only one filter(take negation of the clause/filter). It cannot be used to concatenate 2 filters. So it cannot be used within TableQuery.CombineFilters which needs 2 filters.

    If you want to use the TableOperators.Not, you should directly use it in the where clause, like below:

    TableQuery<CustomerEntity> myquery = new TableQuery<CustomerEntity>()
                    .Where(TableOperators.Not + "(Email eq 'ivanyang1@hotmail.com')");