ADO.NET Provider for GitHub

Build 23.0.8847

DataAdapter を使用したクエリ

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

GitHubDataAdapter の使用

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

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber";

using (GitHubConnection connection = new GitHubConnection(connectionString)) {
  GitHubDataAdapter dataAdapter = new GitHubDataAdapter(
  "SELECT Name, OwnerLogin FROM Repositories", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber"

Using connection As New GitHubConnection(connectionString)
  Dim dataAdapter As New GitHubDataAdapter("SELECT Name, OwnerLogin FROM Repositories", connection)

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

  Console.WriteLine("Contents of Repositories.")

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

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