ADO.NET Provider for Asana

Build 22.0.8479

DataAdapter を使用したクエリ

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

AsanaDataAdapter の使用

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

次の例は、projects テーブルのId カラムとWorkspaceId カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='http://localhost:33333'";

using (AsanaConnection connection = new AsanaConnection(connectionString)) {
  AsanaDataAdapter dataAdapter = new AsanaDataAdapter(
  "SELECT Id, WorkspaceId FROM projects", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='http://localhost:33333'"

Using connection As New AsanaConnection(connectionString)
  Dim dataAdapter As New AsanaDataAdapter("SELECT Id, WorkspaceId FROM projects", connection)

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

  Console.WriteLine("Contents of projects.")

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

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8479