ADO.NET Provider for Neo4j

Build 23.0.8839

DataAdapter を使用したクエリ

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

Neo4jDataAdapter の使用

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

次の例は、ProductCategory テーブルのCategoryId カラムとCategoryName カラムを選択します。

C#

string connectionString = "server=localhost;port=7474;user=neo4j;password=password;";

using (Neo4jConnection connection = new Neo4jConnection(connectionString)) {
  Neo4jDataAdapter dataAdapter = new Neo4jDataAdapter(
  "SELECT CategoryId, CategoryName FROM ProductCategory", connection);

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

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

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

VB.NET

Dim connectionString As String = "server=localhost;port=7474;user=neo4j;password=password;"

Using connection As New Neo4jConnection(connectionString)
  Dim dataAdapter As New Neo4jDataAdapter("SELECT CategoryId, CategoryName FROM ProductCategory", connection)

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

  Console.WriteLine("Contents of ProductCategory.")

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

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