Reputation: 3924
I referred the document and it says
Get the client library by using one of the following methods:
I installed via NuGet package manger console
var client = new CouchbaseClient();
I didn't get reference for this class CouchbaseClient;
Am i doing wrong or how to rectify this ?
And the code which is working for me is ,
Cluster objCluster = new Cluster();;
IBucket objBucket = objCluster.OpenBucket();
var returnVal = objBucket.GetDocument<dynamic>("strKey").Content;
//For upserting
objBucket.Upsert(strkey, objDoc);
This is working for me.
Problem in this is :
All the inserts are falling into default bucket.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="couchbase">
<section name="bucket-1" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/>
</sectionGroup>
</configSections>
<couchbase>
<bucket-1>
<servers bucket="default">
<add uri="http://10.0.0.1:8091/pools/default"/>
</servers>
</bucket-1>
</couchbase>
</configuration>
In that bucket="default" i changed default to other bucket. Still couldn't succeeded.
Please clarify me in two things:
And in the configuration what exactly i need to change ?
UPDATE :
If i removed the dll added via nuget and added via the one present in zip that class is coming. But Still didn't succeeded in the config part and also why the change in nuget and the package.
Which one to follow ? The document is explained with dlls in zip.
Upvotes: 1
Views: 2143
Reputation: 28351
CouchbaseClient
is from older versions of the SDK (< 2.0). Latest NuGet package is indeed version 2+.
The snippet of code you provided is ok using SDK 2.0.
Where is the documentation you referred to? Where did you download the zip?
I'm not entirely sure about the client configuration's schema, but I don't think what you did does anything. OpenBucket()
always opens the "default" bucket (hardcoded), and you should use OpenBucket(BucketName, BucketPassword)
to open a different one.
Also, for the cluster to take your App.config into account at all, it must be created using the constructor that takes the config section as a parameter: new Cluster("couchbase/bucket-1");
. This is usually useful for bootstrapping configuration ( tags) and choosing different ports / activating SSL, since the default constructor will only try to connect on localhost.
See the test configuration for examples.
Upvotes: 2