DataAdapter を使用したクエリ
CData ADO.NET Provider for Bitbucket では、次の2つのネイティブ.NET インターフェースを使用して、Bitbucket からデータを取得できます。BitbucketDataAdapter オブジェクトおよびBitbucketDataReader オブジェクト。各オブジェクトは同じタスク(データの取得)を実行しますが、実行方法が異なります。BitbucketDataAdapter オブジェクトはクエリに一致するすべてのデータを取得しますが、BitbucketDataReader オブジェクトは必要に応じてインクリメントしながら一部のデータだけをフェッチします。
BitbucketDataAdapter の使用
アダプターのFill メソッドを使用して、データソースからデータを取得します。空のDataTable インスタンスがFill メソッドへの引数として渡されます。このメソッドが戻ってきたとき、DataTable インスタンスにはクエリされたデータが設定されています。Fill メソッドは、戻る前にデータソースからすべてのデータを取得する必要があるため、BitbucketDataAdapter はBitbucketDataReader よりも時間がかかります。
次の例は、Issues テーブルのTitle カラムとContentRaw カラムを選択します。
C#
string connectionString = "Workspace=myworkspaceslug;Schema=Information";
using (BitbucketConnection connection = new BitbucketConnection(connectionString)) {
BitbucketDataAdapter dataAdapter = new BitbucketDataAdapter(
"SELECT Title, ContentRaw FROM Issues", connection);
DataTable table = new DataTable();
dataAdapter.Fill(table);
Console.WriteLine("Contents of Issues.");
foreach (DataRow row in table.Rows) {
Console.WriteLine("{0}: {1}", row["Title"], row["ContentRaw"]);
}
}
VB.NET
Dim connectionString As String = "Workspace=myworkspaceslug;Schema=Information"
Using connection As New BitbucketConnection(connectionString)
Dim dataAdapter As New BitbucketDataAdapter("SELECT Title, ContentRaw FROM Issues", connection)
Dim table As New DataTable()
dataAdapter.Fill(table)
Console.WriteLine("Contents of Issues.")
For Each row As DataRow In table.Rows
Console.WriteLine("{0}: {1}", row("Title"), row("ContentRaw"))
Next
End Using