Skip to content

Sgawrys/RedisGraphDotNet.Client

Repository files navigation

RedisGraphDotNet.Client

License: MIT Build Status Nuget (with prereleases)

A C# client library for RedisGraph.

How to use

Add the client library NuGet package to your project:

dotnet add package RedisGraphDotNet.Client

Examples

Initializing the 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);

Creating nodes

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)");

Querying for nodes, relations, and properties

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");

Deleting the graph database

redisGraphClient.DeleteGraph("myTestGraphDatabase");

Running Tests

Run tests with the following command:

dotnet test

The tests currently expect Redis to be running locally on 6379.

About

A C# client library for the RedisGraph Redis module.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages