Skip to content
Brian Chavez edited this page Oct 29, 2015 · 80 revisions

RethinkDb.Driver is a ReQL driver for RethinkDB. This driver is closely ported from the official Java driver.

This C# driver strives for 100% API compatibility and ReQL completeness.

Getting Started

NuGet Package RethinkDb.Driver

Install-Package RethinkDb.Driver -Pre

If you're using CoreCLR, you may need to manually restore Microsoft.Extensions.Logging references from:

dnu restore --fallbacksource https://www.myget.org/F/aspnetvnext/api/v2/

Documentation

You should be able to follow any examples found in the official ReQL documentation for the Java driver. However, the official Java driver documentation is unavailable at the time of this writing.

In the meantime, the ReQL JavaScript API documentation can suffice. However, there are some known deviations between the official Java API and JavaScript APIs. For example, specifying optional arguments:

Example Query with Optional Arguments
r.table('marvel').getAll('man_of_steel', {index:'code_name'})
                 .run(conn, callback)

The Java driver (and C# driver supports) the use of .optArg() method calls to specify optional arguments. The equivalent query in Java (and C#) is shown below:

Cursor<Foo> foo = r.db(DbName).table("marvel")
                   .getAll("man_of_steel")
                       .optArg("index", "code_name")
                   .run<Foo>(conn);

The C# driver also supports anonymous typed optional arguments. ReQL expressions in other drivers usually specify optional arguments last. The following syntax follows this convention via indexers. The equivalent query above can also be written as:

Cursor<Foo> foo = r.db(DbName).table("marvel")
                   .getAll("man_of_steel")[new {index="code_name"}]
                   .run<Foo>(conn);

Poco Support

This C# driver supports POCO serialization to RethinkDB via Newtonsoft.Json. If you have very unique POCO serialization requirements, you can override the default PocoConverter method.

Converter.PocoConverter = (poco) =>
      {
         return JObject.FromObject(poco, /*with custom serialization*/);
      }

Keep in mind, there are some native types that RethinkDB expects in a specific JSON format. Native ReQL types time and dates (DateTime and DateTimeOffset) need to be in a specific format in order to perform ReQL operations on them. By default, native ReQL types are converted automatically; however, if you override the default PocoConverter you will need to ensure DateTime and DateTimeOffset get converted correctly.

Driver Development

If you're interested in making a contribution or want to build the driver manually, these pages will be helpful.

Clone this wiki locally