C# Fluent API for DSE Graph Released
Let's see how this new library can help you write Gremlin traversals from your C# code.
Gremlin.NET Variant and Driver Integration
In the case of the DataStax C# Fluent API, we are using Gremlin.NET language variant that uses C# capitalization and naming conventions, exposing a strongly typed API. You can read more information regarding Gremlin and GLVs on this blog post by Kevin Gallardo.
- Automatic cluster discovery
- Built-in load-balancing features
- Datacenter awareness
- Failure recovery policies
- Speculative executions
- Enterprise-grade client authentication
It was previously possible to use the C# Driver to execute string representations of groovy gremlin traversals on DSE Graph but this new package enables you to write your graph traversals in C#.
Add the package reference to your project file and obtain it from nuget.org:
dotnet add package Dse.Graph
Add the following using directives:
using Dse; using Dse.Graph; using Gremlin.Net;
To execute traversals, you will need a IDseSession instance that represents a pool of connections to your DSE cluster.
IDseCluster cluster = DseCluster.Builder() .AddContactPoint("127.0.0.1") .Build(); IDseSession session = cluster.Connect();
Use your IDseSession instances to obtain GraphTraversalSource instances.
GraphTraversalSource g = DseGraph.Traversal(session);
GraphTraversalSource from Gremlin.NET can be used (and reused) to build traversals.
var traversal = g.V().HasLabel("person").Values
ExecuteGraph() extension methods to execute a traversal:
GraphResultSet result = session.ExecuteGraph(traversal);
Or the async counterpart:
GraphResultSet result = await session.ExecuteGraphAsync(traversal);
Alternatively, Traversals can be executed on the server using the methods that represent Gremlin terminal steps. In the case of Gremlin.Net variant, those are
Iterate(), along with
Promise() for async traversal execution.
The documentation for the DataStax C# Driver Fluent API for DSE Graph is located here.
Your feedback is important to us, you can use the following channels to send comments or questions:
- Mailing List: https://groups.google.com/a/lists.datastax.com/forum/#!forum/csharp-driver-user
- Report issues on JIRA: https://datastax-oss.atlassian.net/browse/CSHARP/issues
- DataStax Academy Slack: https://academy.datastax.com/slack