New C# Driver for DataStax Enterprise

Datetime:2016-08-23 00:42:34         Topic: C#          Share        Original >>
Here to See The Original Article!!!

Last week, we released DataStax Enterprise (DSE) 5.0 and, to support the additional features of the platform, we announced the availability of a new set of drivers .

The DataStax Enterprise C# Driver is a new package that depends on the “core” C# driver for Apache Cassandra, exposing new dedicated interfaces IDseCluster and IDseSession , which inherit from ICluster and ISession interfaces respectively, to provide additional capabilities likeDSE Graph support, Unified Authentication and Geospatial types support.

Upgrading from the Core Driver

To Upgrade from CassandraCSharpDriver, change your dependency to the new Dse package , add the Dse namespace.

using Dse;

And create IDseCluster and IDseSession instances.

IDseCluster cluster = DseCluster.Builder()
IDseSession session = cluster.Connect();

Unified Authentication

For clients connecting to a cluster secured with DSE Unified Authentication , two authentication providers are included:

You can specify the authentication provider when initializing the cluster:

using Dse;
using Dse.Auth;
IDseCluster dseCluster = DseCluster.Builder()
    .WithAuthProvider(new DseGssapiAuthProvider())

See the API docs for DsePlainTextAuthProvider and DseGSSAPIAuthProvider for more information.

DSE Graph Support

The DSE driver supports two different query languages: CQL for interacting with Cassandra tables, and Gremlin , the graph traversal language that allows you to interact withDSE Graph.

IDseSession includes the ExecuteGraph() method to execute graph queries:

GraphResultSet rs = session.ExecuteGraph("g.V()");
Vertex vertex = rs.First();

There is also a non-blocking method counterpart, ExecuteGraphAsync() which returns a Task<GraphResultSet> that can be awaited on.

Check out DSE 5.0 Graph documentation more information on DSE Graph / Gremlin and the driver documentation on graph for further information about executing graph queries and setting graph options.

Geospatial Types

DataStax Enterprise 5.0 comes with a set of additional CQL types to represent geospatial data: PointType , LineStringType and PolygonType .

cqlsh> CREATE TABLE points_of_interest(name text PRIMARY KEY, coords 'PointType');
cqlsh> INSERT INTO points_of_interest (name, coords) VALUES ('Eiffel Tower', 'POINT(48.8582 2.2945)');

The DSE driver includes C# representations of these types in the Dse.Geometry namespace that can be used directly as parameters in queries. All C# geospatial types implement ToString() , that returns the string representation in Well-known text format .

using Dse.Geometry;
Row row = session.Execute("SELECT coords FROM points_of_interest WHERE name = 'Eiffel Tower'").First();
Point coords = row.GetValue<Point>("coords");

var statement = new SimpleStatement("INSERT INTO points_of_interest (name, coords) VALUES (?, ?)",
    "Washington Monument", 
    new Point(38.8895, 77.0352));

See the driver documentation on geospatial types for more details.

Looking Forward

We will continue to develop and improve the C# driver for Apache Cassandra as it represents the core building block on which DataStax Enterprise C# Driver is built, and also continue to add DSE-specific functionalities in this new driver.

To provide feedback use the following:

The DSE driver is available on .

Note that the DataStax Enterprise C# Driver is published under specific license terms that allow its usage only in conjunction with DataStax Enterprise software .


Put your ads here, just $200 per month.