About the C# driver

Use this driver in production applications to pass CQL statements from the client to a cluster and retrieve, manipulate, or remove data.

The C# driver is a modern, feature-rich and highly tunable Java client library for Apache Cassandra (1.2+) and DataStax Enterprise (3.1+) using exclusively Cassandra's binary protocol and Cassandra Query Language v3.

Use this driver in production applications to pass CQL statements from the client to a cluster and retrieve, manipulate, or remove data. Cassandra Query Language (CQL) is the primary language for communicating with the Cassandra database. Documentation for CQL is available in CQL for Cassandra 2.x. DataStax also provides DataStax DevCenter, which is a free graphical tool for creating and running CQL statements against Apache Cassandra and DataStax Enterprise. Other administrative tasks can be accomplished using OpsCenter.

Note: The C# 2.0 driver works with Apache Cassandra 1.2 and 2.0, and DataStax Enterprise 4.0, 3.2, and 3.1.

What's new?

Here are the new and noteworthy features of the 2.1 driver.

  • Cassandra 2.0 support
    • Lightweight transactions

      Lightweight transactions have been added to Cassandra 2.0 to enable compare-and-set operations. Since these operations require a distributed consensus, you should not expect performance to be as good as for regular reads and writes, but they make it possible to handle some extra use cases in Cassandra such as stock management for e-commerce websites or unique username allocation.

    • Batching prepared statements

      While in Cassandra 1.2, it was possible to create a PreparedStatement from a BATCH query, Cassandra 2.0 also makes it possible to batch prepared statements, making it much easier for developers to send multiple INSERT or UPDATE statements to Cassandra without the overhead of multiple network round-trips.

    • Parameterized statements

      Sometimes, even though, you need to send a query just once it uses UUIDs or blobs which are inconvenient to serialize in the CQL string. With the 1.0 version of the driver, you might have used a prepared statement for these binary parameters to solve the problem. Cassandra 2.0 introduced parameterized statements which allow you to provide parameters to regular statements, still using the question mark as a placeholder.

    • Automatic result set pagination

      Allows you to iterate indefinitely over the RowSet, having the rows fetched block by block until the rows available on the client side are exhausted. This makes it easier to manipulate large result sets while also shielding the client application from instantiating an accidentally large RowSet object.

    • LZ4 support

      Support for LZ4 comes as an additional compression option in Cassandra 2.0 besides Snappy. LZ4 is known to have a compression ratio roughly equivalent to Snappy while being much faster, both for compression and decompression.

  • API improvements
    • Task support for statement execution

      ExecuteAsync returns a Task<RowSet> that can be awaited, continued, etc.

    • RowSet is now IEnumerable<Row>. You can iterate through the rows using the RowSet without having to invoke the GetRows method.
    • The driver simplifies testability by exposing many components of the driver as interfaces (instead of classes) thus making it possible to mock commonly used interfaces such as ISession, IStatement.