ADO.NET Provider for Azure Table Storage

Build 23.0.8839

DataAdapter を使用したクエリ

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

AzureTablesDataAdapter の使用

アダプターのFill メソッドを使用して、データソースからデータを取得します。空のDataTable インスタンスがFill メソッドへの引数として渡されます。このメソッドが戻ってきたとき、DataTable インスタンスにはクエリされたデータが設定されています。Fill メソッドは、戻る前にデータソースからすべてのデータを取得する必要があるため、AzureTablesDataAdapter はAzureTablesDataReader よりも時間がかかります。

次の例は、NorthwindProducts テーブルのPartitionKey カラムとName カラムを選択します。

C#

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

using (AzureTablesConnection connection = new AzureTablesConnection(connectionString)) {
  AzureTablesDataAdapter dataAdapter = new AzureTablesDataAdapter(
  "SELECT PartitionKey, Name FROM NorthwindProducts", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of NorthwindProducts.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["PartitionKey"], row["Name"]);
  }
}

VB.NET

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

Using connection As New AzureTablesConnection(connectionString)
  Dim dataAdapter As New AzureTablesDataAdapter("SELECT PartitionKey, Name FROM NorthwindProducts", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of NorthwindProducts.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("PartitionKey"), row("Name"))
  Next
End Using

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