A RethinkDB database driver written in C# striving for 100% API compatibility and completeness.
This driver is based on the official Java Driver. This driver and the official Java Driver are still under active development.
The code here is a one-to-one port of the Java driver. The basic mechanics and architecture of both drivers are the same.
NuGet Package RethinkDb.Driver
Install-Package RethinkDb.Driver
public static RethinkDB r = RethinkDB.r;
[Test]
public void can_connect()
{
var c = r.connection()
.hostname("192.168.0.11")
.port(RethinkDBConstants.DEFAULT_PORT)
.timeout(60)
.connect();
var result = r.random(1, 9).add(r.random(1, 9)).run<int>(c);
Console.WriteLine(result);
result.Should().BeGreaterOrEqualTo(2).And.BeLessThan(18);
}
// Output: 8
You should be able to follow any examples found in the ReQL documentation with this driver.
- Visual Studio 2015 Community or higher
- NuGet Package Command Line installed in your PATH via NuGet.org or via Chocolatey.
- (Optional) RazorGenerator to modify CodeGen templates.
git clone https://github.com/bchavez/RethinkDb.Driver.git
cd RethinkDb.Driver
build
If you want to build the nuget package, run:
build pack
The following folders at the root level be generated:
__compile
- Contains the result of the build process.__package
- Contains the result of the packaging process.
build.cmd
- Ensures build enviornment and fowards build commands toBuilder
.Source\Builder
- Primary location where build tasks are defined. SeeBauBuild.cs
.Source\RethinkDb.Driver
- The RethinkDB C# driver.Source\RethinkDb.Driver.Tests
- Driver unit tests.Source\Templates
- Code generation templates.
The build process is similar to the Java driver, except this C# driver
requires JSON metadata files derived from ql2.proto
by the Java Driver's
metajava.py
script. The JSON metadata files are:
proto_basic.json
global_info.json
java_term_info.json
These files reside inside Source/Templates/Metadata.
java_term_info.json
is a special file (not to be confused with term_info.json
).
java_term_info.json
is a more refined output of term_info.json
that includes extra metadata to support Java language semantics when producing RethinkDB's AST. java_term_info.json
generated
by running the following command in the Java driver's directory:
python metajava.py --term-info term_info.json --output-file java_term_info.json generate-java-terminfo
If you wish to update the C# AST classes (and enums) you first
need to re-generate *.json
files from metajava.py
script that resides the Java driver. Then
copy/overwrite the *.json
files in Source/Templates/Metadata
.
The build codegen
task will use the *.json
files to regenerate all the AST C# classes; which, in effect, runs Templates\GeneratorForAst.cs:Generate_All()
.
The code generator templates are located in Source/Templates/CodeGen/
.
The templates are RazorGenerator templates. Updating any of the *.cshtml
code generation
templates requires installing RazorGenerator's Visual Studio Extension
or using RazorGenerator's MSBuild task to transform the Razor *.cshtml
templates to *.generated.cs
razor code-behind files.