A C# client library for RedisGraph.
Add the client library NuGet package to your project:
dotnet add package RedisGraphDotNet.Client
Initialize the client by specifying Redis server address and port:
var redisGraphClient = new RedisGraphClient("localhost", 6739);
Initialize the client by providing a ConnectionMultiplexer:
var connectionMultiplexer = ConnectionMultiplexer.Connect("localhost", 6739);
// Other code here.
var redisGraphClient = new RedisGraphClient(connectionMultiplexer);
Create a singular node:
redisGraphClient.Query("myTestGraphDatabase", "CREATE (:myTestNode)");
Create a node with properties:
redisGraphClient.Query("myTestGraphDatabase", "CREATE (:myTestNode { myTestProperty: 1 })");
Create multiple nodes:
redisGraphClient.Query("myTestGraphDatabase", "CREATE (a:myTestNode),(b:myTestNode)");
Create a node with a relationship to another node:
// Creates two nodes with label 'myTestNode' with a 'parent' relationship type.
redisGraphClient.Query("myTestGraphDatabase", "CREATE (a:myTestNode)-[:parent]->(b:myTestNode)");
Retrieve node(s) with label myTestNode
:
redisGraphClient.Query("myTestGraphDatabase", "MATCH (a:myTestNode) RETURN a");
Retrieve node(s) with a parent
relationship type:
redisGraphClient.Query("myTestGraphDatabase", "MATCH (a)->[:parent]->(b) RETURN a,b");
redisGraphClient.DeleteGraph("myTestGraphDatabase");
Run tests with the following command:
dotnet test
The tests currently expect Redis to be running locally on 6379.