ADO.NET Provider for Azure Table Storage

Build 23.0.8839

DataReader を使用したクエリ

CData ADO.NET Provider for Azure Table Storage では、次の2つのネイティブ.NET インターフェースを使用して、Azure Table Storage からデータを取得できます。AzureTablesDataAdapter オブジェクトおよびAzureTablesDataReader オブジェクト。各オブジェクトは同じタスク(データの取得)を実行しますが、実行方法が異なります。AzureTablesDataAdapter オブジェクトはクエリに一致するすべてのデータを取得しますが、AzureTablesDataReader オブジェクトは必要に応じてインクリメントしながら一部のデータだけをフェッチします。

AzureTablesDataReader の使用

AzureTablesDataReader はページ単位でデータを取得できるため、AzureTablesDataAdapter よりもデータの取得が高速です。AzureTablesDataReader からデータを読み取っていくと、必要に応じて一定の間隔で、データソースからの結果の次のページが要求されます。このため、結果が高速に返されます。 次の例は、NorthwindProducts テーブルからすべてのカラムを選択します。

C#

string connectionString = "AccessKey=myAccessKey;Account=myAccountName;";

using (AzureTablesConnection connection = new AzureTablesConnection(connectionString)) {
  AzureTablesCommand cmd = new AzureTablesCommand("SELECT * FROM NorthwindProducts", connection);
  
  AzureTablesDataReader rdr = cmd.ExecuteReader();

  while (rdr.Read()) {
    Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["PartitionKey"], rdr["Name"]));
  }
}

VB.NET

Dim connectionString As String = "AccessKey=myAccessKey;Account=myAccountName;"

Using connection As New AzureTablesConnection(connectionString)
  Dim cmd As New AzureTablesCommand("SELECT * FROM NorthwindProducts", connection)

  Dim rdr As AzureTablesDataReader = cmd.ExecuteReader()

  While rdr.Read()
    Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("PartitionKey"), rdr("Name")))
  End While
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839