Conexión con couchbase y query con n1ql
var config = new ClientConfiguration
{
Servers = Servers
//ObserveTimeout = 24000,
//DefaultOperationLifespan = 24000,
//BucketConfigs = new Dictionary<string, BucketConfiguration>()
//{
// {
// "HCBS", new BucketConfiguration
// {
// BucketName = "HCBS",
// UseSsl = false,
// Password = "",
// DefaultOperationLifespan = 240000,
// PoolConfiguration = new PoolConfiguration
// {
// MaxSize = 10,
// MinSize = 5,
// SendTimeout = 240000,
// WaitTimeout = 240000,
// ShutdownTimeout = 240000
// },
// ObserveTimeout = 240000,
// }
// }
//}
};
using (var cluster = new Cluster(config))
{
IBucket bucket = null;
try
{
bucket = cluster.OpenBucket("HCBS");
string query = string.Format("SELECT meta(content).id as id, content FROM HCBS content WHERE content.hotelCode = {0} and content.isGood == true", code.ToString());
var result = bucket.Query<dynamic>(query);
if (result.Success)
{
result.Rows.ForEach(row =>
{
CouchbaseLine cl = new CouchbaseLine()
{
id = row.id,
key = row.content.hotelCode,
value = row.content.value
};
myList.rows.Add(cl);
});
myList.total_rows = result.Rows.Count();
}
}
finally
{
if (bucket != null)
{
cluster.CloseBucket(bucket);
}
}
}