Querying with the DataAdapter
The CData ADO.NET Provider for Neo4j implements two ADO.NET interfaces you can use to retrieve data from Neo4j: Neo4jDataAdapter and Neo4jDataReader objects. Whereas Neo4jDataAdapter objects retrieve a single result set of all the data that matches a query, Neo4jDataReader objects fetch data in subset increments as needed.
Using the Neo4jDataAdapter
Use the adapter's Fill method to retrieve data from the data source. An empty DataTable instance is passed as an argument to the Fill method. When the method returns, the DataTable instance is populated with the queried data. Note that the Neo4jDataAdapter is slower than the Neo4jDataReader because the Fill method needs to retrieve all data from the data source before returning.
The following example selects the CategoryId and CategoryName columns of the ProductCategory table:
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