1
votes

I am trying to query against the table storage but I am getting the following error:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<code>InvalidInput</code>

<message xml:lang="en-US">One of the request inputs is not valid.</message>

</error>

The code I use is as follows:

public IEnumerable<ShoppingItemEntity> Get(string shoppingRowKey) {

    var ctx = getTableServiceContext();
    var shoppingItems = ctx.CreateQuery<ShoppingItemEntity>(
        Constants.TABLE_STORAGE_SHOPPING_ITEM_TABLE_NAME
    ).Where(x => x.PartitionKey == string.Empty && x.ShoppingId == shoppingRowKey).AsTableServiceQuery();

    return shoppingItems.ToList();
}

private TableServiceContext getTableServiceContext() {

    var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
    return account.CreateCloudTableClient().GetDataServiceContext();
}

The strange thing here is that if I run the query without where clause, I get no errors:

public IEnumerable<ShoppingItemEntity> Get(string shoppingRowKey) {

    var ctx = getTableServiceContext();
    var shoppingItems = ctx.CreateQuery<ShoppingItemEntity>(
        Constants.TABLE_STORAGE_SHOPPING_ITEM_TABLE_NAME
    ).AsTableServiceQuery();

    return shoppingItems.ToList();
}

What do u think is the problem here?

1

1 Answers

4
votes

There are articles here and here shows the similar experience you have had with Azure Table storage. When dealing with Azure Development Storage you really need to “convince” the table service provider that you know what you are doing by inserting some dummy entities.

I believe you sure like this article Azure Table Storage, what a pain in the ass.