Getting started in 5min

If you are working with Hypertable for .NET for the first time take your chance and run through this Quick Tour to get started in a few minutes. We assume that you have downloaded the Hypertable for .NET client library already, either the x86 or the x64 assembly, and that you have access to a running Hypertable instance. Get the complete C# sample (or C++ /CLI sample) code from github.


Creating a database connection

To be able to communicate with the database create a connection context defined by a connection string first. The connection string defines the provider to be used and the connection endpoint. Hypertable for .NET supports the following inbuilt providers:

Hyper net.tcp://host[:port] Native Hypertable client protocol
Thrift net.tcp://host[:port] Hypertable Thrift API
SQLite file://[drive][/path]/filename Embedded key-value store, based on SQLite
Hamster file://[drive][/path]/filename Embedded key-value store, based on hamsterdb


Now, establish a context and create a client:

var connectionString = "Provider=Hyper;Uri=net.tcp://localhost";
using (var context = Context.Create(connectionString))
using (var client = context.CreateClient()) {


Creating a namespace and table

To be able to work successfully with the database tables open or create a namespace first:

using (var ns = client.OpenNamespace(
                       OpenDispositions.OpenAlways|OpenDispositions.CreateIntermediate)) {


Once the namespace is available you'll be ready to create or open a table:

const string TableSchema =
   "<Schema>" +
   "<AccessGroup name=\"default\">" +
   "<ColumnFamily><Name>color</Name></ColumnFamily>" +
   "<ColumnFamily><Name>energy</Name></ColumnFamily>" +
   "<ColumnFamily><Name>protein</Name></ColumnFamily>" +
   "<ColumnFamily><Name>vitamins</Name></ColumnFamily>" +
   "</AccessGroup>" +

using (var table = ns.OpenTable(
                      OpenDispositions.OpenAlways)) {

Alternatively, make use of HQL to achieve the same result:

if (!ns.TableExists("fruits")) {
   ns.Exec("CREATE TABLE fruits(color, energy, protein, vitamins)");

using (var table = ns.OpenTable("fruits")) {


Inserting cells into a table

To insert new cells into a table, update cells or delete existing cells from a table you have to obtain a table mutator. For example, to add some fruits to the table you have created before proceed as follows:

using (var mutator = table.CreateMutator()) {
   // apple
   var key = new Key { Row = "apple", ColumnFamily = "color" };
   mutator.Set(key, Encoding.UTF8.GetBytes("red"));

   key.ColumnFamily = "energy";
   mutator.Set(key, BitConverter.GetBytes(207)); // [KJ]

   key.ColumnFamily = "vitamins";
   key.ColumnQualifier = "C";
   mutator.Set(key, BitConverter.GetBytes(15.0)); // [mg]

   key.ColumnQualifier = "B1";
   mutator.Set(key, BitConverter.GetBytes(0.02)); // [mg]

   // banana
   key = new Key { Row = "banana", ColumnFamily = "color" };
   mutator.Set(key, Encoding.UTF8.GetBytes("yellow"));

   key.ColumnFamily = "energy";
   mutator.Set(key, BitConverter.GetBytes(375)); // [KJ]

   key.ColumnFamily = "vitamins";
   key.ColumnQualifier = "C";
   mutator.Set(key, BitConverter.GetBytes(10.0)); // [mg]

   key.ColumnQualifier = "B1";
   mutator.Set(key, BitConverter.GetBytes(0.04)); // [mg]


Selecting cells from a table

To issue table queries you have to obtain a table scanner. For example, to select the entire table you have created before proceed as follows:

// SELECT * FROM fruits;
using (var scanner = table.CreateScanner()) {
   foreach (var cell in scanner) {

If you want to be more selective make use of some predicates:

// SELECT vitamins FROM fruits WHERE ROW = 'banana';
var scanSpec = new ScanSpec("banana").AddColumn("vitamins");
using (var scanner = table.CreateScanner(scanSpec)) {
   Cell cell;
   while (scanner.Next(out cell)) {


We hope that with this Quick Tour we have raised your interest in the Hypertable for .NET client library and that we have managed to successfully guide you through it. For more comprehensive details on Hypertable for .NET refer to the documentation or the latest API reference.