ADO.NET Provider for Marketo

Build 23.0.8839

DataAdapter を使用したクエリ

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

MarketoDataAdapter の使用

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

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

C#

string connectionString = "Schema=REST;RESTEndpoint=https://MyMarketoUrl/rest;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;";

using (MarketoConnection connection = new MarketoConnection(connectionString)) {
  MarketoDataAdapter dataAdapter = new MarketoDataAdapter(
  "SELECT Id, Email FROM Leads", connection);

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

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

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

VB.NET

Dim connectionString As String = "Schema=REST;RESTEndpoint=https://MyMarketoUrl/rest;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;"

Using connection As New MarketoConnection(connectionString)
  Dim dataAdapter As New MarketoDataAdapter("SELECT Id, Email FROM Leads", connection)

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

  Console.WriteLine("Contents of Leads.")

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

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