under dev storage, i've created a number of tables which all have "myprefix" prefix in the table name. when i execute the following code, listtables("myprefix") never returns an entry:

    [ClassCleanup]
     public static void ClassCleanup()
     {
         var tableClient = _account.CreateCloudTableClient();
         foreach (var table in tableClient.ListTables("myprefix"))
         {
             tableClient.DeleteTableIfExist(table);
         }
     }

it does return all the tables if i use listtables(), not sure why the prefix overload does not work. any suggestions?

有帮助吗?

解决方案

I believe this is a bug in development storage. I looked at the code for ListTables(prefix) and this is what I found (pasting only a part of ListTablesSegmentedImplCore() method):

if (prefix != string.Empty)
            {                       
                // Append Max char to end  '{' is 1 + 'z' in AsciiTable
                string uppperBound = prefix + '{';

                query = query.Where((table) => table.TableName.CompareTo(prefix) >= 0 && table.TableName.CompareTo(uppperBound) < 0);
            }

So what's happening is that a query is constructed which is something like:

http://[your dev storage table endpoint]/devstoreaccount1/Tables()?$filter=(TableName ge 'a') and (TableName lt 'a{')

Now we know that dev storage uses SQL Server behind the scenes for data storage. If I take this query and execute it's equivalent against that SQL Server database, I did not get any result back:

SELECT TOP 1000 [AccountName]
  ,[TableName]
  ,[LastModificationTime]
  ,[ServiceMetadata]
  ,[Metadata]
  ,[SchemaXml] FROM [DevelopmentStorageDb201206].[dbo].[TableContainer]   Where [TableName] >= 'a' and [TableName] < 'a{'

I guess, in the interim you would need to do the filtering on your end. Also please be aware that there's another bug we discovered long time back in development storage and that has to do with continuation token for tables. When you list tables and there're more than 1000 tables in your storage account, you don't get back a continuation token when fetching tables in development storage.

Hope this helps.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top