ADO.NET Provider for Freshdesk

Build 23.0.8839

DataAdapter を使用したクエリ

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

FreshDeskDataAdapter の使用

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

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

C#

string connectionString = "Domain=MyDomain;APIKey=myAPIKey;";

using (FreshDeskConnection connection = new FreshDeskConnection(connectionString)) {
  FreshDeskDataAdapter dataAdapter = new FreshDeskDataAdapter(
  "SELECT Id, Name FROM Tickets", connection);

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

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

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

VB.NET

Dim connectionString As String = "Domain=MyDomain;APIKey=myAPIKey;"

Using connection As New FreshDeskConnection(connectionString)
  Dim dataAdapter As New FreshDeskDataAdapter("SELECT Id, Name FROM Tickets", connection)

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

  Console.WriteLine("Contents of Tickets.")

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

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