Cannot Reproduce
Pinned fields
Click on the next to a field label to start pinning.
Details
Details
Assignee
Michael Nitschinger
Michael NitschingerReporter
Alex Cavnar
Alex CavnarStory Points
1
Components
Fix versions
Affects versions
Priority
Instabug
Open Instabug
PagerDuty
PagerDuty
Sentry
Sentry
Zendesk Support
Zendesk Support
Created December 17, 2019 at 1:36 AM
Updated April 24, 2020 at 8:23 PM
Resolved March 15, 2020 at 5:56 AM
I'm noticing some odd behavior when trying to do GetAsync<T> where T is a class I've specified. I would have expected that GetAsync<T> would have returned the document I've inserted, but it appears that it's returning the document within a document, with a field name of "".
Here's some sample code illustrating the issue, plus a workaround:
var connString = "couchbase://10.0.0.220"; var options = new ClusterOptions(); options.WithBucket("bugtest") .WithCredentials("Administrator", "danger") .WithServers(connString); var cluster = new Cluster(connString, options); var bucketResult = cluster.BucketAsync("bugtest"); bucketResult.Wait(); var collection = bucketResult.Result.DefaultCollection(); var testData = new TestData() { StringTest = "test", IntTest = Int32.MaxValue, DictTest = new Dictionary<string, int>(){ {"key1", 1}, {"key2", 2}, {"key3", 3} } }; var key = "test:mydoc"; collection.InsertAsync(key, testData); var getResult = collection.GetAsync(key, options => { }); getResult.Wait(); var r = getResult.Result; var badResult = r.ContentAs<TestData>(); // this should return the object we inserted, but it does not /* It looks like it's returning a document that looks like this: {"" : {<the actual document content>}} */ //this is the workaround for Get var correctResult = (JToken)(r.ContentAs<dynamic>()[""]); var cr = (TestData)correctResult.ToObject(typeof(TestData)); //this returns what I would have expected.