Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Couchbase Essentials

You're reading from  Couchbase Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784394493
Pages 170 pages
Edition 1st Edition
Languages

Couchbase .NET SDK


The Couchbase .NET SDK is a purely C#-based library. Currently, the latest version is 2.0. This version contains support for .NET 4.5+.

Current version

This SDK should be used for all development purposes against all Couchbase Server versions from 2.5 to 3.x. Version 1.3 of the SDK was developed to support earlier versions of Couchbase Server.

How to obtain it

The .NET developers will most likely want to use NuGet to add the Couchbase .NET SDK to their Visual Studio projects. To install Couchbase SDK 2.0, run the following command in Package Manager Console:

PM> Install-Package CouchbaseNetClient

Additionally, the SDK team publishes the .NET binaries, which can be found at http://docs.couchbase.com/developer/dotnet-2.0/download-links.html. The source code for the library is available on GitHub at https://github.com/couchbase/couchbase-net-client.

The basics

The following snippet demonstrates the basics of using the Couchbase .NET SDK:

//Configure the cluster defaulting to "127.0.0.1"
var cluster = new Cluster();

//Open a bucket connection defaulting to "default"
var bucket = cluster.OpenBucket();

//Create, and store a JSON document
var document = new Document<dynamic> { 
  Id = "somekey", {
    Content = new { Message = "Hello, World!" };
bucket.Upsert(document);

//Read the document
var savedMessage = bucket.GetDocument<dynamic>("somekey");

// Close the bucket connection
bucket.Dispose();
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}