ADO.NET Provider for Azure Data Catalog

Build 23.0.8839

DataAdapter を使用したクエリ

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

AzureDataCatalogDataAdapter の使用

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

次の例は、Tables テーブルのDslAddressDatabase カラムとType カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;";

using (AzureDataCatalogConnection connection = new AzureDataCatalogConnection(connectionString)) {
  AzureDataCatalogDataAdapter dataAdapter = new AzureDataCatalogDataAdapter(
  "SELECT DslAddressDatabase, Type FROM Tables", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;"

Using connection As New AzureDataCatalogConnection(connectionString)
  Dim dataAdapter As New AzureDataCatalogDataAdapter("SELECT DslAddressDatabase, Type FROM Tables", connection)

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

  Console.WriteLine("Contents of Tables.")

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

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