Querying with the DataReader
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 Neo4jDataReader
The Neo4jDataReader retrieves data faster than the Neo4jDataAdapter because it can retrieve data in pages. As you read data from the Neo4jDataReader, it periodically requests the next page of results from the data source, if required. This causes results to be returned at a faster rate. The following example selects all the columns from the ProductCategory table:
C#
string connectionString = "server=localhost;port=7474;user=neo4j;password=password;"; using (Neo4jConnection connection = new Neo4jConnection(connectionString)) { Neo4jCommand cmd = new Neo4jCommand("SELECT * FROM ProductCategory", connection); Neo4jDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["CategoryId"], rdr["CategoryName"])); } }
VB.NET
Dim connectionString As String = "server=localhost;port=7474;user=neo4j;password=password;" Using connection As New Neo4jConnection(connectionString) Dim cmd As New Neo4jCommand("SELECT * FROM ProductCategory", connection) Dim rdr As Neo4jDataReader = cmd.ExecuteReader() While rdr.Read() Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("CategoryId"), rdr("CategoryName"))) End While End Using