2012-02-23 1 views

答えて

3

RetryPolicyを使用する必要はありません。 2つのオプションがあります。

クエリで.AsTableServiceQuery()を使用します。これは、クエリをCloudTableQuery <>オブジェクトに変換します。このオブジェクトは、継続トークンをネイティブに処理します。これは最も簡単なルートです。例:

var query = (from r in Rows 
      where r.PartitionKey == "whatever" 
      select r).AsTableServiceQuery(); 

それ以外の場合は、Begin/EndExecuteSegmented()を使用して、自分でトークンを処理できます。 > CloudTableQuery <上

明確化

Scott Densmore's blog上CloudTableQuery <の行動に対して斜め参照>があります。しかし、私はまたそれを証明するために次の、むしろ乱雑なコードを投げました。テストに合格し、継続トークンを使用して挿入されたすべてのエンティティを取得します。 HTTPを使用している場合は、FiddlerでHTTPを視聴し、トークンが前後に移動するのを確認できます。それは言及テキスト内

 [Test, Explicit] 
     public void WriteAndReadALotOfRows() 
     { 
      CloudStorageAccount acct = CloudStorageAccount.Parse("PUT IN SOME CREDS HERE"); 
      TableServiceContext ctx = null; 
      List<TestEntity> testEntities = new List<TestEntity>(2000); 

      acct.CreateCloudTableClient().CreateTableIfNotExist("Test"); 

      //Create entities 
      for (int i = 0; i < 2000; i++) 
      { 
       if (i % 100 == 0) 
       { 
        if (ctx != null) 
        { 
         ctx.SaveChangesWithRetries(SaveChangesOptions.Batch); 
        } 

        ctx = new TableServiceContext(acct.TableEndpoint.AbsoluteUri, acct.Credentials); 
       } 
       TestEntity entity = new TestEntity(i); 
       testEntities.Add(entity); 
       ctx.AddObject("Test", entity); 
      } 

      ctx.SaveChangesWithRetries(SaveChangesOptions.Batch); 

      ctx = new TableServiceContext(acct.TableEndpoint.AbsoluteUri, acct.Credentials); 

      List<TestEntity> retrievedEntities = (from r in ctx.CreateQuery<TestEntity>("Test") 
                select r).AsTableServiceQuery().ToList(); 

      Assert.AreEqual(testEntities.Count, retrievedEntities.Count); 
      Console.Out.WriteLine(retrievedEntities.Count); //prints 2000 

      foreach (var insertedEntity in testEntities) 
      { 
       TestEntity retrievedEntity = retrievedEntities.First(r => r.RowKey == insertedEntity.RowKey); 
       Assert.NotNull(retrievedEntity); 
      } 
     } 

     public class TestEntity : TableServiceEntity 
     { 
      public TestEntity() 
      { 
      } 

      public TestEntity(int id) 
       : base("Test", id.ToString()) 
      { 

      } 
     } 
+0

だからCloudTableQuery'ネイティブ継続トークンを扱う '言うの?私にティについての参考資料を教えてください。もしそうなら、私は既にカバーされています。 –

+1

本当に良いリファレンスは見つかりませんでしたが、ポイントを証明するためのサンプルコードを書いて追加しました。 –

1

チェックアウトhttp://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx

表のクエリは - あなたがCloudTableQueryを使用してクエリを実行すると、それはでreceieved 継続トークンを使用してクエリを再発行するので、それは、 取り扱い継続トークンの世話をします以前のクエリ要求で、残りのエンティティは になります。上述のように、サービスへのトークンクエリの再発行された各継続は、1トランザクションとしてカウントされる。

またhttp://blogs.msdn.com/b/jimoneil/archive/2010/10/05/azure-home-part-7-asynchronous-table-storage-pagination.aspxhttp://scottdensmore.typepad.com/blog/2010/04/paging-with-windows-azure-table-storage.html

関連する問題