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 basic mechanics and architecture of both drivers are the same.
NuGet Package RethinkDb.Driver
Install-Package RethinkDb.Driver -Pre
While CoreCLR is still in beta, an additional restore fallback source is needed to restore Microsoft.Extensions.Logging.Abstractions
reference:
dnu restore --fallbacksource https://www.myget.org/F/aspnetvnext/api/v2/
Supported Runtimes
<th><img src='https://github.com/Turbo87/Font-Awesome/raw/platform-icons/svg/windows.png'/> Windows</th>
<th><img src='https://github.com/Turbo87/Font-Awesome/raw/platform-icons/svg/linux.png'> Linux</th>
<th><img src='https://github.com/Turbo87/Font-Awesome/raw/platform-icons/svg/apple.png'/> Mac OS X</th>
Mono | All platforms 4.0.2 SR2 or higher | ||
CoreCLR | All platforms 1.0.0-rc1-final or higher | ||
.NET Framework | v4.5 | n/a | n/a |
RethinkDB server 2.2.0 or higher |
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();
int 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
[Test]
public void insert_poco_without_id()
{
var obj = new Foo { Bar = 1, Baz = 2};
var result = r.db(DbName).table(TableName).insert(obj).run(conn);
result.Dump();
}
/*
//JObject: Insert Response
{
"deleted": 0,
"errors": 0,
"generated_keys": [
"6931c97f-de3d-46d2-b0f9-956af9517a57"
],
"inserted": 1,
"replaced": 0,
"skipped": 0,
"unchanged": 0
}
*/
[Test]
public void insert_an_array_of_pocos()
{
var list = new[]
{
new Foo {id = "a", Baz = 1, Bar = 1},
new Foo {id = "b", Baz = 2, Bar = 2},
new Foo {id = "c", Baz = 3, Bar = 3}
};
var result = r.db(DbName).table(TableName).insert(list).run(conn);
result.Dump();
}
/*
//JObject Insert Response
{
"deleted": 0,
"errors": 0,
"inserted": 3,
"replaced": 0,
"skipped": 0,
"unchanged": 0
}
*/
[Test]
public void get_a_poco()
{
Foo foo = r.db(DbName).table(TableName).get("abc").run<Foo>(conn);
foo.Dump();
}
//Foo Object
/*
{
"id": "abc",
"Bar": 1,
"Baz": 2
}
*/
If you'd like to contribute, please consider reading some helpful tips before making changes.
Created by Brian Chavez. Originally ported from the Java Driver by Josh Kuhn.
A big thanks to GitHub and all contributors: