Hi.
Using .Net SDK 2.4.8 and Couchbase version 4.5.0-2601 Enterprise Edition (build-2601)
I have Couchbase Enterprise Edition running through Docker on my laptop. I have a small program where I query the a bucket to retrieve an ID. When I use ‘Query<>’ it works and returns the correct data but when I use ‘QueryAsync<>’ the program crashes on me without any explanation. Code is below:
Program.cs
using Couchbase;
using Couchbase.Configuration.Client;
using System;
using System.Collections.Generic;
namespace CouchbaseQuery
{
class Program
{
static void Main(string[] args)
{
var config = new ClientConfiguration()
{
Servers = new List<Uri>
{
new Uri("http://localhost:8091/")
},
BucketConfigs = new Dictionary<string, BucketConfiguration>
{
{
"FeatureValue", new BucketConfiguration
{
BucketName = "FeatureValue",
UseSsl = false,
Password = "",
DefaultOperationLifespan = 2000,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 10,
MinSize = 5,
SendTimeout = 12000
}
}
}}
};
ClusterHelper.Initialize(config);
new Couchbase().DeleteFeature().ConfigureAwait(false);
}
}
}
Couchbase.cs
using Couchbase; using System; using System.Threading.Tasks; using Couchbase.N1QL; namespace CouchbaseQuery { public class Couchbase { public async Task DeleteFeature() { var bucket = ClusterHelper.GetBucket("FeatureValue"); using (bucket) { var featureName = "TestFeatureNamee5ae96a8-2803-495a-b054-ade239890cf6"; var q = new QueryRequest() .Statement("SELECT meta(`FeatureValue`).id FROM `FeatureValue` WHERE featureName = '$1' ") .AddPositionalParameter(featureName); var queryString = $"SELECT meta(`FeatureValue`).id FROM `FeatureValue` WHERE featureName = '{featureName}' "; try { var result = await bucket.QueryAsync<dynamic>(q).ConfigureAwait(false); foreach (var row in result.Rows) { Console.WriteLine(row); } } catch (Exception e) { Console.WriteLine(e); throw; } } } } }
In the couchbase.cs class I have tried using both a query string and a query result. Both give same problem.