.NET is one of the Neo4j supported languages and an official driver is provided. Official drivers connect to the databases using BOLT protocol (HTTP/HTTPS is not available).

📘

About connection parameters

We've used test credentials for all the following examples. Please replace them with your real connection parameters.

You'll find all the required information to connect to your database on our admin panel if you navigate to the Connection section. More on connecting to your database here

This section is intended to provide a small working example to connect to a GrapheneDB database using the Java driver. To get more detailed information, visit the driver web page: https://github.com/neo4j/neo4j-dotnet-driver

This driver is shipped exclusively as a NuGet package. To use them in your projects, you will need to use the Package Manager Console.

To install the .NET Neo4j Driver, run the following command in the Package Manager Console:

PM> Install-Package Neo4j.Driver -Version 4.0.1

📘

Check the driver releases for the newest driver version available.

The following example just sets up the connection and run a simple query of the Movies dataset example:

using System;
using System.Collections.Generic;
using Neo4j.Driver;

namespace testApp
{   
    class Program
    {
        public static async void TestNeo4j()
        {
          IDriver driver = GraphDatabase.Driver("bolt://db-jidgsytyxo1r31sd4ker.graphenedb.com:24786",
            AuthTokens.Basic("admin", "b.P0shGn2gvpUD.9RAHyuY4QXkkUK7w"), o => o.WithEncryptionLevel(EncryptionLevel.Encrypted));

          IAsyncSession session = driver.AsyncSession();

          try
          {
            IResultCursor cursor = await session.RunAsync("MATCH (:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(movies) RETURN movies.title AS title");
            List<string> movies = await cursor.ToListAsync(record => record["title"].As<string>());
            movies.ForEach(i => Console.WriteLine("{0}\t", i));
          }
          finally
          {
            await session.CloseAsync();
          }

          await session.CloseAsync();
        }

        static void Main(string[] args)
        {
          TestNeo4j();
          Console.ReadLine();
        }
    }     
}

You can also use the new bolt+s URI scheme to enable encryption with a full certificate check:

IDriver driver = GraphDatabase.Driver("bolt+s://db-jidgsytyxo1r31sd4ker.graphenedb.com:24786",
            AuthTokens.Basic("admin", "b.P0shGn2gvpUD.9RAHyuY4QXkkUK7w"));

Updated about a month ago

.NET


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.